Class URLUtils

java.lang.Object
com.webmethods.caf.faces.render.util.URLUtils

public class URLUtils extends Object
URL utility functions.
  • Field Details

  • Constructor Details

    • URLUtils

      public URLUtils()
  • Method Details

    • registerURLFactory

      public static void registerURLFactory(URLUtils.IURLFactory urlFactory, boolean highPriority)
    • createRenderURL

      public static IURL createRenderURL(FacesContext context)
      Creates a PortletURL based on the current request, even if request isn't a portlet request. (If it isn't a portlet request, the PortletURL parameters are 'global').
    • isRenderRequest

      public static boolean isRenderRequest(FacesContext context)
    • createSharedResourceURLEncoder

      public static URLUtils.ISharedResourceURLEncoder createSharedResourceURLEncoder(String frontEndUrl, String sharedContexPath, Object encoderDelegate)
    • createSharedResourceURLEncoder

      public static URLUtils.ISharedResourceURLEncoder createSharedResourceURLEncoder(Object encoderDelegate)
    • createSharedResourceURL

      public static String createSharedResourceURL(FacesContext context, String path)
      Creates url to CAF shared resource.
      Parameters:
      context - Current context.
      path - Resource path relative to wm_cafshared war (ie '/base.js').
      Returns:
      Encoded, absolute url to resource.
    • createSharedResourceURL

      public static String createSharedResourceURL(FacesContext context, String base, String path)
      Creates url to CAF resource in a war other than wm_cafshared.
      Parameters:
      context - Current context.
      base - War name (ie 'wm_myportlet').
      path - Resource path relative to shared war (ie '/custom.js').
      Returns:
      Encoded, absolute url to resource.
    • encodeImageURL

      public static String encodeImageURL(FacesContext context, String url)
      Encodes unencoded image url. Also maps a named skinned image to its concrete image url.
      Parameters:
      context - Current context.
      url - Unencoded image url.
      Returns:
      Encoded, absolute url reference.
    • addAppVersionToUrl

      public static String addAppVersionToUrl(FacesContext context, String url)
      Adds app version param (v=) to specified url.
      Parameters:
      context - Current context.
      url - Url to add.
      Returns:
      Url with added version param.
    • isImageSkinned

      public static boolean isImageSkinned(FacesContext context, String imageName)
      Returns true if the image is skinned, false if un-skinned.
      Parameters:
      context - Current context.
      imageName - Image name, like "SelectAll.gif" (not "images/SelectAll.gif" or "/skin/images/SelectAll.gif").
      Returns:
      True if image exists in current skin.
    • getFrontEndURL

      public static String getFrontEndURL(Object delegate)
      Calculate front-end url for current request, up to but not including context path for current war. Must not include a trailing slash. Ex: "http://foo", "https://foo.example.com:8443", "http://foo/portal".
    • isSafeURLScheme

      public static boolean isSafeURLScheme(String url)
      True if url uses safe scheme (like "http:", "ftp:", etc.), false if null, empty string, or not sure.
    • appendURLParameters

      public static String appendURLParameters(String url, Map<String,?> parameters)
      Append parameters specified by map to existing url. Does not check for paramaters already exsting in url.
      Parameters:
      url - Url. May be null or empty. May include query part.
      parameters - Map of parameters. May be null or empty.
      Returns:
      Url with appended paramaters. Never null.
    • encodeURIComponent

      public static String encodeURIComponent(String s)
      Encode a string to the "x-www-form-urlencoded" form, enhanced with the UTF-8-in-URL proposal. This is what happens:
      • The ASCII characters 'a' through 'z', 'A' through 'Z', and '0' through '9' remain the same.

      • The unreserved characters - _ . ! ~ * ' ( ) remain the same.

      • The space character ' ' is not converted into a plus sign '+'.

      • All other ASCII characters are converted into the 3-character string "%xy", where xy is the two-digit hexadecimal representation of the character code

      • All non-ASCII characters are encoded in two steps: first to a sequence of 2 or 3 bytes, using the UTF-8 algorithm; secondly each of these bytes is encoded as "%xx".

    • decodeURIComponent

      public static String decodeURIComponent(String s)
      Decodes from URL-escaped format.
    • getSharedResourceBase

      public static String getSharedResourceBase(FacesContext context, String base)
    • createSharedResourceURLforFe

      public static String createSharedResourceURLforFe(FacesContext context, String path)
    • getSharedContextPath

      public static String getSharedContextPath(FacesContext context)