Package com.ocpsoft.pretty.faces.config.mapping

Examples of com.ocpsoft.pretty.faces.config.mapping.UrlMapping


   private void processEvent(final PhaseEvent event)
   {
      FacesContext context = event.getFacesContext();

      PrettyContext prettyContext = PrettyContext.getCurrentInstance(context);
      UrlMapping mapping = prettyContext.getCurrentMapping();
      if (mapping != null)
      {
         executor.executeActions(context, event.getPhaseId(), mapping);
      }
   }
View Full Code Here


      try
      {

         PrettyContext prettyContext = PrettyContext.getCurrentInstance(context);
         PrettyConfig prettyConfig = prettyContext.getConfig();
         UrlMapping urlMapping = prettyConfig.getMappingById(mappingId);

         String href = context.getExternalContext().getRequestContextPath()
               + urlBuilder.build(urlMapping, true, urlBuilder.extractParameters(component));

         if ((link.getAnchor() != null) && link.getAnchor().length() > 0)
View Full Code Here

     
      String relative = (String) urlBuffer.getAttributes().get("relative");

      PrettyContext prettyContext = PrettyContext.getCurrentInstance(context);
      PrettyConfig prettyConfig = prettyContext.getConfig();
      UrlMapping urlMapping = prettyConfig.getMappingById(mappingId);

      String prettyHref = urlBuilder.build(urlMapping, true, urlBuilder.extractParameters(component));
      String contextPath = context.getExternalContext().getRequestContextPath();
      String href = (relative == null || "false".equals(relative)) ? contextPath + prettyHref : prettyHref;
View Full Code Here

         log.error("Cannot build script because PrettyContext is not available!");
         return null;
      }

      // find UrlMapping in configuration
      UrlMapping mapping = prettyContext.getConfig().getMappingById(mappingId.trim());
      if (mapping == null)
      {
         log.error("Cannot find URL mapping with id: " + mappingId);
         return null;
      }
View Full Code Here

   }

   @Test
   public void testParseWithQueryValidators() throws Exception
   {
      UrlMapping mapping = config.getMappingById("validate");
      List<QueryParameter> params = mapping.getQueryParams();
      assertEquals(1, params.size());

      QueryParameter p = params.get(0);
      assertEquals("validator1 validator2", p.getValidatorIds());
      assertEquals("pretty:demo", p.getOnError());
View Full Code Here

   }

   @Test
   public void testQueryParameterOnPostbackAttribute() throws Exception
   {
      UrlMapping mapping = config.getMappingById("8");
      List<QueryParameter> params = mapping.getQueryParams();
      assertEquals(3, params.size());

      assertEquals("withoutAttribute", params.get(0).getName());
      assertEquals(true, params.get(0).isOnPostback());
View Full Code Here

         Collections.sort(matches, ORDINAL_COMPARATOR);

         Iterator<UrlMapping> iterator = matches.iterator();
         while (iterator.hasNext())
         {
            UrlMapping m = iterator.next();

            if (m.isOutbound())
            {
               List<UIParameter> uiParams = new ArrayList<UIParameter>();

               Map<String, String[]> queryParams = queryString.getParameterMap();

               List<PathParameter> pathParams = m.getPatternParser().getPathParameters();

               int pathParamsFound = 0;
               for (PathParameter p : pathParams)
               {
                  UIParameter uip = new UIParameter();
View Full Code Here

            encodeURL(externalContext, config, target);
            return true;
         }
         else if (isPrettyNavigationCase(prettyContext, action))
         {
            UrlMapping mapping = config.getMappingById(action);
            if (mapping != null)
            {
               String target = contextPath + builder.buildURL(mapping).encode()
                        + builder.buildQueryString(mapping);
               log.trace("Redirecting to mappingId [" + mapping.getId() + "], [" + target + "]");
               encodeURL(externalContext, config, target);
            }
            else
            {
               throw new PrettyException("PrettyFaces: Invalid mapping id supplied to navigation handler: " + action);
View Full Code Here

      // no mappings added
      assertNotNull(config.getMappings());
      assertEquals(1, config.getMappings().size());

      // validate mapping properties
      UrlMapping mapping = config.getMappings().get(0);
      assertEquals("simple", mapping.getId());
      assertEquals("/some/url", mapping.getPattern());
      assertEquals("/view.jsf", mapping.getViewId());
      assertEquals(false, mapping.isOutbound());
      assertEquals(false, mapping.isOnPostback());
      assertEquals(0, mapping.getActions().size());
      assertEquals(0, mapping.getQueryParams().size());
      assertEquals(0, mapping.getPathValidators().size());

   }
View Full Code Here

    *
    * @return True if the id is found, false if not.
    */
   public boolean isMappingId(final String id)
   {
      UrlMapping mapping = getMappingById(id);
      return mapping instanceof UrlMapping;
   }
View Full Code Here

TOP

Related Classes of com.ocpsoft.pretty.faces.config.mapping.UrlMapping

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.