Package com.ocpsoft.pretty

Examples of com.ocpsoft.pretty.PrettyContext


            // inject parameters
            injector.injectParameters(event.getFacesContext());
         }

         PrettyContext prettyContext = PrettyContext.getCurrentInstance(event.getFacesContext());
         if (prettyContext.shouldProcessDynaview())
         {
            dynaview.processDynaView(prettyContext, event.getFacesContext());
         }
         else if (!event.getFacesContext().getResponseComplete())
         {
View Full Code Here


   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

      /*
       * When this method is called for forms, getBookmarkableURL is NOT called; therefore, we have a way to distinguish
       * the two.
       */
      String result = parent.getActionURL(context, viewId);
      PrettyContext prettyContext = PrettyContext.getCurrentInstance(context);
      if (!isBookmarkable() && prettyContext.isPrettyRequest() && !prettyContext.isInNavigation() && (viewId != null)
               && viewId.equals(context.getViewRoot().getViewId()))
      {
         ExtractedValuesURLBuilder builder = new ExtractedValuesURLBuilder();
         UrlMapping mapping = prettyContext.getCurrentMapping();
         result = prettyContext.getContextPath() + builder.buildURL(mapping) + builder.buildQueryString(mapping);
      }
      return result;
   }
View Full Code Here

    * Add PrettyFaces UIViewParameters to the component tree. This is how we do value injection, conversion, and
    * validation.
    */
   private void addPrettyViewParameters(final FacesContext context, final UIViewRoot view)
   {
      PrettyContext prettyContext = PrettyContext.getCurrentInstance(context);
      if (prettyContext.isPrettyRequest())
      {
         UIComponent metadata = view.getFacet(UIViewRoot.METADATA_FACET_NAME);
         if (metadata == null)
         {
            metadata = context.getApplication().createComponent(UIPanel.COMPONENT_TYPE);
            view.getFacets().put(UIViewRoot.METADATA_FACET_NAME, metadata);
         }

         List<UIComponent> children = metadata.getChildren();

         List<PathParameter> pathParameters = prettyContext.getCurrentMapping().getPatternParser().getPathParameters();
         for (PathParameter p : pathParameters)
         {
            UIViewParameter param = (UIViewParameter) context.getApplication().createComponent(
                     UIViewParameter.COMPONENT_TYPE);

            Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
            requestMap.put(p.getName(), p.getValue());
            param.setName(p.getName());

            ValueExpression ve = elUtils.createValueExpression(context, p.getExpression().getELExpression());
            param.setValueExpression("value", ve);
            param.setImmediate(true);
            children.add(param);
         }

         List<QueryParameter> queryParams = prettyContext.getCurrentMapping().getQueryParams();
         for (QueryParameter q : queryParams)
         {
            UIViewParameter param = new UIViewParameter();
            param.setName(q.getName());

View Full Code Here

         log.error("Please set either 'mappingId' or 'url' attribute!");
         return null;
      }

      // try to obtain PrettyContext
      PrettyContext prettyContext = PrettyContext.getCurrentInstance(behaviorContext.getFacesContext());
      if (prettyContext == null)
      {
         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;
      }

      try
      {

         // build path to redirect to
         ExtractedValuesURLBuilder builder = new ExtractedValuesURLBuilder();
         String contextPath = prettyContext.getContextPath();
         String path = contextPath + builder.buildURL(mapping) + builder.buildQueryString(mapping);

         // return the script
         return buildScriptInternal(path);
View Full Code Here

    *
    * @return JSF viewID to which this request resolves.
    */
   public String computeDynaViewId(final FacesContext facesContext)
   {
      PrettyContext context = PrettyContext.getCurrentInstance(facesContext);
      UrlMapping urlMapping = context.getCurrentMapping();

      return calculateDynaviewId(facesContext, urlMapping);
   }
View Full Code Here

   public String calculateDynaviewId(final FacesContext facesContext, UrlMapping urlMapping)
   {
      String result = "";
      if (urlMapping != null)
      {
         PrettyContext context = PrettyContext.getCurrentInstance(facesContext);

         String viewId = urlMapping.getViewId();
         if (viewId == null)
         {
            viewId = "";
         }
         while (elUtils.isEl(viewId))
         {
            Object viewResult = elUtils.invokeMethod(facesContext, viewId);
            if (viewResult == null)
            {
               viewId = "";
               break;
            }
            else
            {
               viewId = viewResult.toString();
            }

            if (context.getConfig().isMappingId(viewId))
            {
               urlMapping = context.getConfig().getMappingById(viewId);
               viewId = urlMapping.getViewId();
               ExtractedValuesURLBuilder builder = new ExtractedValuesURLBuilder();
               result = context.getContextPath() + builder.buildURL(urlMapping).encode()
                         + builder.buildQueryString(urlMapping);
            }
            else
            {
               result = viewId;
            }
         }
         if ("".equals(viewId))
         {
            log.debug("ViewId for mapping with id <" + urlMapping.getId() + "> was blank");
         }
         result = context.stripContextPath(result);
      }
      return result;
   }
View Full Code Here

   public boolean redirect(final FacesContext context, final String action)
   {
      try
      {
         PrettyContext prettyContext = PrettyContext.getCurrentInstance(context);
         PrettyConfig config = prettyContext.getConfig();
         ExternalContext externalContext = context.getExternalContext();

         String contextPath = prettyContext.getContextPath();
         if (PrettyContext.PRETTY_PREFIX.equals(action) && prettyContext.isPrettyRequest())
         {
            URL url = prettyContext.getRequestURL();
            QueryString query = prettyContext.getRequestQueryString();

            String target = contextPath + url.encode().toURL() + query.toQueryString();
            log.trace("Refreshing requested page [" + url + "]");
            String redirectUrl = externalContext.encodeRedirectURL(target, null);
            externalContext.redirect(redirectUrl);
View Full Code Here

   {
      log.debug("Navigation requested: fromAction [" + fromAction + "], outcome [" + outcome + "]");
      if (!pr.redirect(context, outcome))
      {
         log.debug("Not a PrettyFaces navigation string - passing control to default nav-handler");
         PrettyContext prettyContext = PrettyContext.getCurrentInstance(context);
         prettyContext.setInNavigation(true);

         String originalViewId = context.getViewRoot().getViewId();
         parent.handleNavigation(context, fromAction, outcome);
         String newViewId = context.getViewRoot().getViewId();

         /*
          * Navigation is complete if the viewId has not changed or the response is complete
          */
         if ((true == context.getResponseComplete()) || originalViewId.equals(newViewId))
         {

            prettyContext.setInNavigation(false);
         }
      }

   }
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;
View Full Code Here

TOP

Related Classes of com.ocpsoft.pretty.PrettyContext

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.