Package com.ocpsoft.pretty.faces.config

Examples of com.ocpsoft.pretty.faces.config.PrettyConfig


            throw new RuntimeException(ex);
        }
        BeanManager beanManager = (BeanManager) sc.getAttribute(BeanManagerServletContextListener.BEANMANAGER_SERVLETCONTEXT_KEY);
        ViewConfigStore store = BeanManagerUtils.getContextualInstance(beanManager, ViewConfigStore.class);
        List<UrlMapping> mappings = loadUrlMappings(store, webXmlParser.getFacesMapping());
        PrettyConfig prettyConfig = new PrettyConfig();
        prettyConfig.setMappings(mappings);
        return prettyConfig;
    }
View Full Code Here


   public Configuration getConfiguration(final ServletContext context)
   {
      ConfigurationBuilder builder = ConfigurationBuilder.begin();

      PrettyConfig config = (PrettyConfig) context.getAttribute(PrettyContext.CONFIG_KEY);
      if (config != null)
      {
         List<RewriteRule> rules = config.getGlobalRewriteRules();
         List<UrlMapping> mappings = config.getMappings();

         for (RewriteRule rule : rules) {
            builder.addRule(new InboundRewriteRuleAdaptor(rule));
         }
View Full Code Here

      reloader.reloadIfNecessary(servletContext);

      // we need the PrettyConfig later, so save it as a request attribute
      if (request.getAttribute(PrettyContext.CONFIG_KEY) == null)
      {
         PrettyConfig config = (PrettyConfig) servletContext.getAttribute(PrettyContext.CONFIG_KEY);
         request.setAttribute(PrettyContext.CONFIG_KEY, config);
      }

      // build the PrettyContext and attach it to the request
      if (request.getAttribute(UrlMappingRuleAdaptor.REWRITE_MAPPING_ID_KEY) == null) {
View Full Code Here

{
   @Override
   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);

         return query.getParameterMap();
View Full Code Here

   @Override
   public NavigationCase getNavigationCase(final FacesContext context, final String fromAction, final String outcome)
   {
      PrettyContext prettyContext = PrettyContext.getCurrentInstance(context);
      PrettyConfig config = prettyContext.getConfig();
      if ((outcome != null) && PrettyContext.PRETTY_PREFIX.equals(outcome))
      {
         String viewId = context.getViewRoot().getViewId();
         NavigationCase navigationCase = parent.getNavigationCase(context, fromAction, viewId);
         return navigationCase;
      }
      else if ((outcome != null) && outcome.startsWith(PrettyContext.PRETTY_PREFIX) && config.isMappingId(outcome))
      {
         /*
          * FIXME this will not work with dynamic view IDs... figure out another solution
          * (<rewrite-view>/faces/views/myview.xhtml</rewrite-view> ? For now. Do not support it.
          */
         UrlMapping mapping = config.getMappingById(outcome);
         String viewId = mapping.getViewId();
         if (mapping.isDynaView())
         {
            viewId = dynaview.calculateDynaviewId(context, 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

      handler.visit(NotAnnotatedClass.class);

      // build configuration
      PrettyConfigBuilder configBuilder = new PrettyConfigBuilder();
      handler.build(configBuilder);
      PrettyConfig config = configBuilder.build();

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

   }
View Full Code Here

      config = (PrettyConfig) request.getAttribute(CONFIG_KEY);

      // not sure if this can happen any more, but we'll keep it for now
      if (config == null)
      {
         config = new PrettyConfig();
      }

      contextPath = request.getContextPath();
      String requestUrl = stripContextPath(request.getRequestURI());
      Matcher sessionIdMatcher = JSESSIONID_PATTERN.matcher(requestUrl);
View Full Code Here

      handler.visit(ClassWithSimpleMapping.class);

      // build configuration
      PrettyConfigBuilder configBuilder = new PrettyConfigBuilder();
      handler.build(configBuilder);
      PrettyConfig config = configBuilder.build();

      // 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());
View Full Code Here

TOP

Related Classes of com.ocpsoft.pretty.faces.config.PrettyConfig

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.