Package com.ocpsoft.pretty.faces.url

Examples of com.ocpsoft.pretty.faces.url.URL


      if (event instanceof HttpInboundServletRewrite)
      {
         ((HttpServletRewrite) event).getRequest().setAttribute(REWRITE_MAPPING_ID_KEY,
                  REWRITE_MAPPING_ID_KEY + ":" + mapping.getId());

         URL url = context.getRequestURL();
         if (context.shouldProcessDynaview())
         {
            log.trace("Forwarding mapped request [" + url.toURL() + "] to dynaviewId [" + context.getDynaViewId() + "]");
            ((HttpInboundServletRewrite) event).forward(context.getDynaViewId());
         }
         else
         {
            String viewId = mapping.getViewId();
            log.trace("Forwarding mapped request [" + url.toURL() + "] to resource [" + viewId + "]");
            if (url.decode().toURL().equals(viewId))
            {
               ((HttpServletRewrite) event).proceed();
            }
            else
            {
View Full Code Here


   public Map<String, String[]> getAdditionalParameters(final ServletRequest request, final ServletResponse response)
   {
      PrettyContext context = PrettyContext.getCurrentInstance((HttpServletRequest)request);
      PrettyConfig config = context.getConfig();

      URL url = context.getRequestURL();
      if (config.isURLMapped(url))
      {
         List<PathParameter> params = context.getCurrentMapping().getPatternParser().parse(url);
         QueryString query = QueryString.build(params);
View Full Code Here

               UIParameter firstParam = parameters.get(0);
               if (((firstParam.getValue() != null)) && (firstParam.getName() == null))
               {
                  if (firstParam.getValue() instanceof List<?>)
                  {
                     URL url = parser.getMappedURL(firstParam.getValue());
                     return url.toURL();
                  }
                  else if (firstParam.getValue().getClass().isArray())
                  {
                     // The Object[] cast here is required, otherwise Java treats
                     // getValue() as a single Object.
                     List<Object> list = Arrays.asList((Object[]) firstParam.getValue());
                     URL url = parser.getMappedURL(list);
                     return url.toURL();
                  }
               }
            }
  
            for (UIParameter parameter : parameters)
            {
               String name = parameter.getName();
               Object value = parameter.getValue();
  
               if ((name == null) && (value != null))
               {
                  pathParams.add(value.toString());
               }
               else
               {
                  List<?> values = null;
                  if ((value != null) && value.getClass().isArray())
                  {
                     values = Arrays.asList((Object[]) value);
                  }
                  else if (value instanceof List<?>)
                  {
                     values = (List<?>) value;
                  }
                  else if (value != null)
                  {
                     values = Arrays.asList(value);
                  }
  
                  if (values != null)
                  {
                     for (Object object : values)
                     {
                        String tempValue = null;
                        if (object != null)
                        {
                           tempValue = object.toString();
                        }
                        queryParams.add(new QueryParameter(name, tempValue));
                     }
                  }
                  else
                  {
                     queryParams.add(new QueryParameter(name, null));
                  }
               }
            }
         }

         // build URL object for given path parameter set
         URL mappedURL = parser.getMappedURL(pathParams.toArray());
        
         // create encoded/unicode URL
         String url = encodeUrl ? mappedURL.encode().toURL() : mappedURL.toURL();
        
         // append query string
         result = url + QueryString.build(queryParams).toQueryString();
        
      }
View Full Code Here

   public void validateParameters(final FacesContext context)
   {
      log.trace("Validating parameters.");
      PrettyContext prettyContext = PrettyContext.getCurrentInstance(context);
      URL url = prettyContext.getRequestURL();
      UrlMapping mapping = prettyContext.getCurrentMapping();

      if (mapping != null)
      {
         validatePathParams(context, url, mapping);
View Full Code Here

   }

   @Test
   public void testGetMappingForUrl()
   {
      UrlMapping mapping2 = config.getMappingForUrl(new URL("/home/en/test/"));
      assertEquals(mapping, mapping2);
   }
View Full Code Here

   }

   @Test
   public void testIsURLMapped() throws Exception
   {
      assertTrue(config.isURLMapped(new URL("/home/en/test/")));
      assertFalse(config.isViewMapped("/home/en/notmapped/okthen"));
   }
View Full Code Here

   public void injectParameters(final FacesContext context)
   {
      log.trace("Injecting parameters");
      PrettyContext prettyContext = PrettyContext.getCurrentInstance(context);
      URL url = prettyContext.getRequestURL();
      UrlMapping mapping = prettyContext.getCurrentMapping();

      if (mapping != null)
      {
         injectPathParams(context, url, mapping);
View Full Code Here

         {
            viewId = dynaview.calculateDynaviewId(context, mapping);
         }
         viewId = FacesNavigationURLCanonicalizer.normalizeRequestURI(context, viewId);

         URL url = new URL(viewId);
         url.getMetadata().setLeadingSlash(true);
         QueryString qs = QueryString.build("");
         if (viewId.contains("?"))
         {
            qs.addParameters(viewId);
         }
         qs.addParameters("?" + PrettyFacesWrappedResponse.REWRITE_MAPPING_ID_KEY + "=" + mapping.getId());

         viewId = url.toString() + qs.toQueryString();

         NavigationCase navigationCase = parent.getNavigationCase(context, fromAction, viewId);
         return navigationCase;
      }
      else
View Full Code Here

    * @param mapping Mapping for which to extract values and generate URL
    * @return The fully constructed URL
    */
   public URL buildURL(final UrlMapping mapping)
   {
      URL result = null;

      String expression = "";
      Object value = null;
      try
      {
View Full Code Here

         requestUrl = sessionIdMatcher.replaceFirst(JSESSIONID_REPLACEMENT);
      }

      String encoding = request.getCharacterEncoding() == null ? DEFAULT_ENCODING : request.getCharacterEncoding();

      requestURL = new URL(requestUrl);
      requestURL.setEncoding(encoding);
      requestURL = requestURL.decode();

      requestQuery = QueryString.build(request.getQueryString());
View Full Code Here

TOP

Related Classes of com.ocpsoft.pretty.faces.url.URL

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.