[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...

Gavin King gavin.king at jboss.com
Tue May 29 19:06:01 EDT 2007


  User: gavin   
  Date: 07/05/29 19:06:01

  Modified:    src/main/org/jboss/seam/core  Pages.java
  Log:
  fix JBSEAM-1359, store page parameters in view root before doing login redirect
  
  Revision  Changes    Path
  1.117     +17 -23    jboss-seam/src/main/org/jboss/seam/core/Pages.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Pages.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Pages.java,v
  retrieving revision 1.116
  retrieving revision 1.117
  diff -u -b -r1.116 -r1.117
  --- Pages.java	29 May 2007 02:56:42 -0000	1.116
  +++ Pages.java	29 May 2007 23:06:01 -0000	1.117
  @@ -295,8 +295,13 @@
       */
      public void postRestorePage(FacesContext facesContext)
      {
  -      String viewId = getViewId(facesContext);
  +      //first store the page parameters into the viewroot, so 
  +      //that if a login redirect occurs, or if a failure
  +      //occurs while applying to the model, we can still make
  +      //Redirect.captureCurrentView() work.
  +      storeRequestParameterValuesInViewRoot(facesContext);
         
  +      String viewId = getViewId(facesContext);      
         for ( Page page: getPageStack(viewId) )
         {         
            if ( isNoConversationRedirectRequired(page) )
  @@ -320,16 +325,9 @@
            }
         }
   
  -      //apply page parameters to the model
  +      //now apply page parameters to the model
         //(after checking permissions)
  -      if ( !facesContext.getRenderResponse() )
  -      {
  -         Pages.instance().applyViewRootValues(facesContext);
  -      }
  -      //absolutely have to do this, otherwise we get
  -      //some wierd behavior with back buttons, since
  -      //params on a h:commandLink will get ignored
  -      Pages.instance().applyRequestParameterValues(facesContext);
  +      applyViewRootValues(facesContext);
      }
      
      private boolean isNoConversationRedirectRequired(Page page)
  @@ -663,14 +661,8 @@
         }
      }
      
  -   /**
  -    * Apply any page parameters passed as parameter values to the model.
  -    */
  -   public void applyRequestParameterValues(FacesContext facesContext)
  +   private void storeRequestParameterValuesInViewRoot(FacesContext facesContext)
      {
  -      //first store the page parameters into the viewroot, so that if
  -      //we fail while applying to the model, we can still make
  -      //Redirect.captureCurrentView() work.
         String viewId = getViewId(facesContext);
         Map<String, String[]> requestParameters = Parameters.getRequestParameters();
         for ( Page page: getPageStack(viewId) )
  @@ -680,23 +672,25 @@
               Object value = pageParameter.getValueFromRequest(facesContext, requestParameters);
               if (value==null)
               {
  +               if ( facesContext.getRenderResponse() ) //ie. for a non-faces request
  +               {
  +                  //this should not be necessary, were it not for a MyFaces bug
                  Contexts.getPageContext().remove( pageParameter.getName() );
               }
  +               //TODO: add some support for required=true
  +            }
               else
               {
                  Contexts.getPageContext().set( pageParameter.getName(), value );
               }
            }
         }
  -      
  -      //now apply them to the model
  -      applyViewRootValues(facesContext);
      }
      
      /**
       * Apply any page parameters passed as view root attributes to the model.
       */
  -   public void applyViewRootValues(FacesContext facesContext)
  +   private void applyViewRootValues(FacesContext facesContext)
      {
         String viewId = getViewId(facesContext);
         for ( Page page: getPageStack(viewId) )
  
  
  



More information about the jboss-cvs-commits mailing list