Examples of UrlMapping


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

         // create an action for each referenced mapping
         for (String mappingId : actionSpec.getMappingIds())
         {

            // Get the mapping references by the action
            UrlMapping mapping = urlMappings.get(mappingId);

            /*
             * Fail for unresolved mappings. This may happen when the user places
             * invalid mapping IDs in the mappingId attribute of
             *
             * @URLAction or @URLQueryParameter
             */
            if (mapping == null)
            {
               throw new IllegalArgumentException("Unable to find the mapping '" + mappingId
                        + "' referenced at method '" + actionSpec.getMethod().getName() + "' in class '"
                        + actionSpec.getMethod().getDeclaringClass().getName() + "'.");
            }

            // build UrlMapping
            UrlAction urlAction = new UrlAction();
            urlAction.setPhaseId(actionSpec.getPhaseId());
            urlAction.setOnPostback(actionSpec.isOnPostback());
            urlAction.setInheritable(actionSpec.isInheritable());

            // try to get bean name
            Class<?> clazz = actionSpec.getMethod().getDeclaringClass();

            // build expression
            PrettyExpression expression = buildPrettyExpression(clazz, actionSpec.getMethod().getName());
            urlAction.setAction(expression);

            // trace
            if (log.isTraceEnabled())
            {
               log.trace("Adding action expression '" + urlAction.getAction() + "' to mapping: " + mapping.getId());
            }

            // register this action
            mapping.addAction(urlAction);

         }
      }

      for (QueryParamSpec queryParamSpec : queryParamList)
      {

         // create a query param for each referenced mapping
         for (String mappingId : queryParamSpec.getMappingIds())
         {

            // Get the mapping references by the query param
            UrlMapping mapping = urlMappings.get(mappingId);

            // fail for unresolved mappings
            if (mapping == null)
            {
               throw new IllegalArgumentException("Unable to find the mapping '" + mappingId
                        + "' referenced at field '" + queryParamSpec.getFieldName() + "' in class '"
                        + queryParamSpec.getOwnerClass().getName() + "'.");
            }

            // build UrlMapping
            QueryParameter queryParam = new QueryParameter();
            queryParam.setName(queryParamSpec.getName());
            queryParam.setOnError(queryParamSpec.getOnError());
            queryParam.setValidatorIds(join(queryParamSpec.getValidatorIds(), " "));
            queryParam.setOnPostback(queryParamSpec.isOnPostback());

            // optional validator method
            if (!isBlank(queryParamSpec.getValidator()))
            {
               queryParam.setValidatorExpression(new ConstantExpression(queryParamSpec.getValidator()));
            }

            // try to get bean name
            Class<?> clazz = queryParamSpec.getOwnerClass();

            // build expression
            PrettyExpression expression = buildPrettyExpression(clazz, queryParamSpec.getFieldName());
            queryParam.setExpression(expression);

            // trace
            if (log.isTraceEnabled())
            {
               log.trace("Registered query-param '" + queryParam.getName() + "' to '" + expression + "' in mapping: "
                        + mapping.getId());
            }

            // register this action
            mapping.addQueryParam(queryParam);

         }

      }

View Full Code Here

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

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

      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

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

     
      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

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

         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

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

   }

   @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

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

   }

   @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

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

         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

Examples of es.internna.framework.annotations.UrlMapping

    }
   
    private void registerController(Object bean, String beanName)
    {
        Class<?> clazz = this.getClass(bean);
        UrlMapping mapping = clazz.getAnnotation(UrlMapping.class);
        if (mapping != null) registerHandler(mapping.value(), beanName);
        UrlMappings mappings = clazz.getAnnotation(UrlMappings.class);
        if (mappings != null)
            for (UrlMapping map : mappings.value())
                registerHandler(map.value(), beanName);
    }
View Full Code Here

Examples of es.internna.framework.annotations.UrlMapping

    }
   
    public final Set<String> getUrlMappings()
    {
        Set<String> combinedMappings = new HashSet<String>(urlMappings);
        UrlMapping urlMapping = ClassUtils.getAnnotation(UrlMapping.class, this);
        if ((urlMapping != null) && (urlMapping.value() != null)) combinedMappings.add(urlMapping.value());
        UrlMappings mappings = ClassUtils.getAnnotation(UrlMappings.class, this);
        if (mappings != null)
            for (UrlMapping map : mappings.value())
                if ((map != null) && (map.value() != null)) combinedMappings.add(map.value());
        return combinedMappings;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.