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

Gavin King gavin.king at jboss.com
Sun Dec 17 14:46:41 EST 2006


  User: gavin   
  Date: 06/12/17 14:46:41

  Modified:    src/main/org/jboss/seam/core     Exceptions.java
                        Manager.java Navigator.java Pages.java
  Log:
  refactor all the inner classes
  
  Revision  Changes    Path
  1.21      +16 -309   jboss-seam/src/main/org/jboss/seam/core/Exceptions.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Exceptions.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Exceptions.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -b -r1.20 -r1.21
  --- Exceptions.java	17 Dec 2006 17:45:37 -0000	1.20
  +++ Exceptions.java	17 Dec 2006 19:46:41 -0000	1.21
  @@ -7,29 +7,29 @@
   import java.util.ArrayList;
   import java.util.List;
   
  -import javax.faces.context.FacesContext;
  -import javax.faces.event.PhaseId;
   
   import org.dom4j.Element;
   import org.jboss.seam.Component;
   import org.jboss.seam.ScopeType;
   import org.jboss.seam.annotations.Create;
  -import org.jboss.seam.annotations.HttpError;
   import org.jboss.seam.annotations.Install;
   import org.jboss.seam.annotations.Intercept;
   import org.jboss.seam.annotations.Name;
  -import org.jboss.seam.annotations.Redirect;
  -import org.jboss.seam.annotations.Render;
   import org.jboss.seam.annotations.Scope;
  -import org.jboss.seam.contexts.Context;
   import org.jboss.seam.contexts.Contexts;
  -import org.jboss.seam.contexts.Lifecycle;
  +import org.jboss.seam.exceptions.ConfigErrorHandler;
  +import org.jboss.seam.exceptions.ConfigRedirectHandler;
  +import org.jboss.seam.exceptions.ConfigRenderHandler;
  +import org.jboss.seam.exceptions.DebugPageHandler;
  +import org.jboss.seam.exceptions.AnnotationErrorHandler;
  +import org.jboss.seam.exceptions.ExceptionHandler;
  +import org.jboss.seam.exceptions.AnnotationRedirectHandler;
  +import org.jboss.seam.exceptions.AnnotationRenderHandler;
   import org.jboss.seam.log.LogProvider;
   import org.jboss.seam.log.Logging;
   import org.jboss.seam.util.Reflections;
   import org.jboss.seam.util.Resources;
   import org.jboss.seam.util.Strings;
  -import org.jboss.seam.util.Transactions;
   import org.jboss.seam.util.XML;
   
   /**
  @@ -42,9 +42,9 @@
   @Intercept(NEVER)
   @Install(precedence=BUILT_IN)
   @Name("org.jboss.seam.core.exceptions")
  -public class Exceptions extends Navigator
  +public class Exceptions
   {
  -   private static final LogProvider log = Logging.getLogProvider(Exceptions.class);
  +   public static final LogProvider log = Logging.getLogProvider(Exceptions.class);
      
      private List<ExceptionHandler> exceptionHandlers = new ArrayList<ExceptionHandler>();
      
  @@ -88,9 +88,9 @@
            }
         }
         
  -      exceptionHandlers.add( new RenderHandler() );
  -      exceptionHandlers.add( new RedirectHandler() );
  -      exceptionHandlers.add( new ErrorHandler() );
  +      exceptionHandlers.add( new AnnotationRenderHandler() );
  +      exceptionHandlers.add( new AnnotationRedirectHandler() );
  +      exceptionHandlers.add( new AnnotationErrorHandler() );
         if ( Init.instance().isDebug() ) 
         {
            exceptionHandlers.add( new DebugPageHandler() );
  @@ -109,35 +109,7 @@
         {
            final String viewId = render.attributeValue("view-id");
            final String message = render.getTextTrim();
  -         return new RenderHandler()
  -         {
  -            @Override
  -            protected String getMessage(Exception e)
  -            {
  -               return message;
  -            }
  -            @Override
  -            protected String getViewId(Exception e)
  -            {
  -               return viewId;
  -            }
  -            @Override
  -            public boolean isHandler(Exception e)
  -            {
  -               return clazz.isInstance(e) && 
  -                     Lifecycle.getPhaseId()==PhaseId.INVOKE_APPLICATION;
  -            }
  -            @Override
  -            protected boolean isEnd(Exception e)
  -            {
  -               return endConversation;
  -            }
  -            @Override
  -            protected boolean isRollback(Exception e)
  -            {
  -               return rollback;
  -            }
  -         };
  +         return new ConfigRenderHandler(message, viewId, clazz, rollback, endConversation);
         }
         
         Element redirect = exception.element("redirect");
  @@ -145,35 +117,7 @@
         {
            final String viewId = redirect.attributeValue("view-id");
            final String message = redirect.getTextTrim();
  -         return new RedirectHandler()
  -         {
  -            @Override
  -            protected String getMessage(Exception e)
  -            {
  -               return message;
  -            }
  -            @Override
  -            protected String getViewId(Exception e)
  -            {
  -               return viewId;
  -            }
  -            @Override
  -            public boolean isHandler(Exception e)
  -            {
  -               return clazz.isInstance(e) && 
  -                     Lifecycle.getPhaseId()!=PhaseId.RENDER_RESPONSE;
  -            }
  -            @Override
  -            protected boolean isEnd(Exception e)
  -            {
  -               return endConversation;
  -            }
  -            @Override
  -            protected boolean isRollback(Exception e)
  -            {
  -               return rollback;
  -            }
  -         };
  +         return new ConfigRedirectHandler(viewId, clazz, endConversation, rollback, message);
         }
         
         Element error = exception.element("http-error");
  @@ -183,249 +127,12 @@
            final int code = Strings.isEmpty(errorCode) ? 
                  500 : Integer.parseInt(errorCode);
            final String message = error.getTextTrim();
  -         return new ErrorHandler()
  -         {
  -            @Override
  -            protected String getMessage(Exception e)
  -            {
  -               return message;
  -            }
  -            @Override
  -            protected int getCode(Exception e)
  -            {
  -               return code;
  -            }
  -            @Override
  -            public boolean isHandler(Exception e)
  -            {
  -               return clazz.isInstance(e);
  -            }
  -            @Override
  -            protected boolean isEnd(Exception e)
  -            {
  -               return endConversation;
  -            }
  -            @Override
  -            protected boolean isRollback(Exception e)
  -            {
  -               return rollback;
  -            }
  -         };
  +         return new ConfigErrorHandler(message, endConversation, clazz, code, rollback);
         }
         
         return null;
      }
   
  -   public static interface ExceptionHandler
  -   {
  -      public Object handle(Exception e) throws Exception;
  -      public boolean isHandler(Exception e);
  -   }
  -   
  -   public static class RedirectHandler implements ExceptionHandler
  -   {
  -      public Object handle(Exception e) throws Exception
  -      {
  -         addFacesMessage( e, getMessage(e) );
  -         if ( isEnd(e) ) Conversation.instance().end();
  -         if ( isRollback(e) ) Transactions.setTransactionRollbackOnly();
  -         redirect( getViewId(e), null );
  -         return rethrow(e);
  -      }
  -
  -      public boolean isHandler(Exception e)
  -      {
  -         return e.getClass().isAnnotationPresent(Redirect.class) && 
  -               Lifecycle.getPhaseId()!=PhaseId.RENDER_RESPONSE && 
  -               Lifecycle.getPhaseId()!=null;
  -      }
  -      
  -      protected String getMessage(Exception e)
  -      {
  -         return e.getClass().getAnnotation(Redirect.class).message();
  -      }
  -      
  -      protected String getViewId(Exception e)
  -      {
  -         return e.getClass().getAnnotation(Redirect.class).viewId();
  -      }
  -      
  -      protected boolean isEnd(Exception e)
  -      {
  -         return e.getClass().getAnnotation(Redirect.class).end();
  -      } 
  -
  -      protected boolean isRollback(Exception e)
  -      {
  -         return e.getClass().getAnnotation(Redirect.class).rollback();
  -      }
  -      
  -      @Override
  -      public String toString()
  -      {
  -         return "RedirectHandler";
  -      }
  -   }
  -   
  -   public static class RenderHandler implements ExceptionHandler
  -   {
  -      public Object handle(Exception e) throws Exception
  -      {
  -         addFacesMessage( e, getMessage(e) );
  -         if ( isEnd(e) ) Conversation.instance().end();
  -         if ( isRollback(e) ) Transactions.setTransactionRollbackOnly();
  -         render( getViewId(e) );
  -         return null;
  -      }
  -
  -      public boolean isHandler(Exception e)
  -      {
  -         return e.getClass().isAnnotationPresent(Render.class) && 
  -               Lifecycle.getPhaseId()==PhaseId.INVOKE_APPLICATION;
  -      }
  -
  -      protected String getMessage(Exception e)
  -      {
  -         return e.getClass().getAnnotation(Render.class).message();
  -      }
  -      
  -      protected String getViewId(Exception e)
  -      {
  -         return e.getClass().getAnnotation(Render.class).viewId();
  -      }
  -
  -      protected boolean isEnd(Exception e)
  -      {
  -         return e.getClass().getAnnotation(Render.class).end();
  -      }
  -
  -      protected boolean isRollback(Exception e)
  -      {
  -         return e.getClass().getAnnotation(Render.class).rollback();
  -      }
  -      
  -      @Override
  -      public String toString()
  -      {
  -         return "RenderHandler";
  -      }
  -   }
  -   
  -   public static class ErrorHandler implements ExceptionHandler
  -   {
  -      public Object handle(Exception e) throws Exception
  -      {
  -         if ( isEnd(e) ) Conversation.instance().end();
  -         if ( isRollback(e) ) Transactions.setTransactionRollbackOnly();
  -         String message = getMessage(e);
  -         //addFacesMessage(e, message);
  -         error( getCode(e), Interpolator.instance().interpolate( getDisplayMessage(e, message) ) );
  -         return rethrow(e);
  -      }  
  -
  -      public boolean isHandler(Exception e)
  -      {
  -         return e.getClass().isAnnotationPresent(HttpError.class);
  -      }
  -      
  -      protected String getMessage(Exception e)
  -      {
  -         return e.getClass().getAnnotation(HttpError.class).message();
  -      }
  -      
  -      protected int getCode(Exception e)
  -      {
  -         return e.getClass().getAnnotation(HttpError.class).errorCode();
  -      }
  -      
  -      protected boolean isEnd(Exception e)
  -      {
  -         return e.getClass().getAnnotation(HttpError.class).end();
  -      }
  -      
  -      protected boolean isRollback(Exception e)
  -      {
  -         return e.getClass().getAnnotation(HttpError.class).rollback();
  -      }
  -      
  -      @Override
  -      public String toString()
  -      {
  -         return "ErrorHandler";
  -      }
  -   }
  -   
  -   public static class DebugPageHandler implements ExceptionHandler
  -   {
  -
  -      public Object handle(Exception e) throws Exception
  -      {
  -         log.error("redirecting to debug page", e);
  -         Context conversationContext = Contexts.getConversationContext();
  -         conversationContext.set("org.jboss.seam.debug.lastException", e);
  -         conversationContext.set("org.jboss.seam.debug.phaseId", Lifecycle.getPhaseId().toString());
  -         org.jboss.seam.core.Redirect redirect = org.jboss.seam.core.Redirect.instance();
  -         redirect.setViewId("/debug.xhtml");
  -         Manager manager = Manager.instance();
  -         manager.beforeRedirect();
  -         redirect.setParameter( manager.getConversationIdParameter(), manager.getCurrentConversationId() );
  -         redirect.execute();
  -         conversationContext.flush();
  -         return rethrow(e);
  -      }
  -
  -      public boolean isHandler(Exception e)
  -      {
  -         return Lifecycle.getPhaseId()!=PhaseId.RENDER_RESPONSE && 
  -               Lifecycle.getPhaseId()!=null;
  -      }
  -      
  -      @Override
  -      public String toString()
  -      {
  -         return "Debug";
  -      }
  -   }
  -   
  -   protected static String getDisplayMessage(Exception e, String message)
  -   {
  -      if ( Strings.isEmpty(message) && e.getMessage()!=null ) 
  -      {
  -         return e.getMessage();
  -      }
  -      else
  -      {
  -         return message;
  -      }
  -   }
  -   
  -   protected static void addFacesMessage(Exception e, String message)
  -   {
  -      message = getDisplayMessage(e, message);
  -      if ( !Strings.isEmpty(message) )
  -      {
  -         FacesMessages.instance().add(message);
  -      }
  -   }
  -   
  -   private static Object rethrow(Exception e) throws Exception
  -   {
  -      //SeamExceptionFilter does *not* do these things, which 
  -      //would normally happen in the phase listener after a 
  -      //responseComplete() call, but because we are rethrowing,
  -      //the phase listener might not get called (due to a bug!)
  -      /*FacesMessages.afterPhase();
  -      if ( Contexts.isConversationContextActive() )
  -      {
  -         Manager.instance().endRequest( ContextAdaptor.getSession( externalContext, true ) );
  -      }*/
  -      
  -      FacesContext facesContext = FacesContext.getCurrentInstance();
  -      facesContext.responseComplete();
  -      facesContext.getExternalContext().getRequestMap().put("org.jboss.seam.exceptionHandled", e);
  -      throw e;
  -   }
  -
      public static Exceptions instance()
      {
         if ( !Contexts.isApplicationContextActive() )
  
  
  
  1.127     +2 -2      jboss-seam/src/main/org/jboss/seam/core/Manager.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Manager.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Manager.java,v
  retrieving revision 1.126
  retrieving revision 1.127
  diff -u -b -r1.126 -r1.127
  --- Manager.java	16 Dec 2006 02:58:10 -0000	1.126
  +++ Manager.java	17 Dec 2006 19:46:41 -0000	1.127
  @@ -42,7 +42,7 @@
    *
    * @author Gavin King
    * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  - * @version $Revision: 1.126 $
  + * @version $Revision: 1.127 $
    */
   @Scope(ScopeType.EVENT)
   @Name("org.jboss.seam.core.manager")
  @@ -991,7 +991,7 @@
            Pages pages = Pages.instance();
            if (pages!=null) //for tests
            {
  -            org.jboss.seam.core.Page pageEntry = pages.getPage(viewId);
  +            org.jboss.seam.pages.Page pageEntry = pages.getPage(viewId);
               if ( pageEntry.isSwitchEnabled() )
               {
                  conversation.setViewId(viewId);
  
  
  
  1.3       +4 -5      jboss-seam/src/main/org/jboss/seam/core/Navigator.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Navigator.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Navigator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- Navigator.java	17 Dec 2006 02:39:17 -0000	1.2
  +++ Navigator.java	17 Dec 2006 19:46:41 -0000	1.3
  @@ -9,14 +9,14 @@
   import org.jboss.seam.log.Logging;
   import org.jboss.seam.util.Strings;
   
  -abstract class Navigator
  +public abstract class Navigator
   {
      private static final LogProvider log = Logging.getLogProvider(Navigator.class);
   
      /**
       * Send an error.
       */
  -   protected static void error(int code, String message)
  +   protected void error(int code, String message)
      {
         if ( log.isDebugEnabled() ) log.debug("sending error: " + code);
         org.jboss.seam.core.HttpError httpError = org.jboss.seam.core.HttpError.instance();
  @@ -33,7 +33,7 @@
      /**
       * Redirect to the view id.
       */
  -   protected static void redirect(String viewId, Map<String, Object> parameters)
  +   protected void redirect(String viewId, Map<String, Object> parameters)
      {
         if ( Strings.isEmpty(viewId) )
         {
  @@ -46,7 +46,7 @@
      /**
       * Render the view id.
       */
  -   protected static void render(String viewId)
  +   protected void render(String viewId)
      {
         FacesContext facesContext = FacesContext.getCurrentInstance();
         if ( !Strings.isEmpty(viewId) )
  @@ -63,5 +63,4 @@
         facesContext.renderResponse();
      }
   
  -
   }
  
  
  
  1.67      +52 -113   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.66
  retrieving revision 1.67
  diff -u -b -r1.66 -r1.67
  --- Pages.java	17 Dec 2006 17:45:37 -0000	1.66
  +++ Pages.java	17 Dec 2006 19:46:41 -0000	1.67
  @@ -17,7 +17,6 @@
   
   import javax.faces.application.ViewHandler;
   import javax.faces.context.FacesContext;
  -import javax.faces.convert.Converter;
   
   import org.dom4j.DocumentException;
   import org.dom4j.Element;
  @@ -32,10 +31,15 @@
   import org.jboss.seam.contexts.Contexts;
   import org.jboss.seam.core.Expressions.MethodBinding;
   import org.jboss.seam.core.Expressions.ValueBinding;
  -import org.jboss.seam.core.Page.ConversationControl;
  -import org.jboss.seam.core.Page.Param;
   import org.jboss.seam.log.LogProvider;
   import org.jboss.seam.log.Logging;
  +import org.jboss.seam.pages.ActionNavigation;
  +import org.jboss.seam.pages.ConversationControl;
  +import org.jboss.seam.pages.Outcome;
  +import org.jboss.seam.pages.Page;
  +import org.jboss.seam.pages.Param;
  +import org.jboss.seam.pages.RedirectNavigationHandler;
  +import org.jboss.seam.pages.RenderNavigationHandler;
   import org.jboss.seam.util.Parameters;
   import org.jboss.seam.util.Resources;
   import org.jboss.seam.util.XML;
  @@ -50,7 +54,7 @@
   @Intercept(NEVER)
   @Name("org.jboss.seam.core.pages")
   @Install(precedence=BUILT_IN)
  -public class Pages extends Navigator
  +public class Pages
   {
      
      private static final LogProvider log = Logging.getLogProvider(Pages.class);
  @@ -89,10 +93,10 @@
       * Run any navigation rule defined in pages.xml
       * 
       * @param actionExpression the action method binding expression
  -    * @param actionOutcome the outcome of the action method
  +    * @param actionOutcomeValue the outcome of the action method
       * @return true if a navigation rule was found
       */
  -   public boolean navigate(FacesContext context, String actionExpression, final String actionOutcome)
  +   public boolean navigate(FacesContext context, String actionExpression, final String actionOutcomeValue)
      {
         String viewId = context.getViewRoot().getViewId();
         if (viewId!=null)
  @@ -101,7 +105,7 @@
            for (int i=stack.size()-1; i>=0; i--)
            {
               Page page = stack.get(i);
  -            Page.ActionNavigation navigation = page.getNavigations().get(actionExpression);
  +            ActionNavigation navigation = page.getNavigations().get(actionExpression);
               if (navigation==null)
               {
                  navigation = page.getDefaultNavigation();
  @@ -110,34 +114,34 @@
               if (navigation!=null)
               {
                  
  -               String outcome;
  +               String outcomeValue;
                  if ( navigation.getOutcomeValueBinding()==null )
                  {
  -                  outcome = actionOutcome;
  +                  outcomeValue = actionOutcomeValue;
                  }
                  else
                  {
                     Object value = navigation.getOutcomeValueBinding().getValue();
  -                  outcome = value==null ? null : value.toString();
  +                  outcomeValue = value==null ? null : value.toString();
                  }
                  
  -               Page.Outcome caze;
  -               if (outcome==null) 
  +               Outcome outcome;
  +               if (outcomeValue==null) 
                  {
                     //JSF navhandler says ignore all rules when null outcome.
                     //so we have a special case for that
  -                  caze = navigation.getNullOutcome();
  +                  outcome = navigation.getNullOutcome();
                  }
                  else
                  {
  -                  caze = navigation.getOutcomes().get(outcome);
  -                  if (caze==null) caze = navigation.getAnyOutcome();
  +                  outcome = navigation.getOutcomes().get(outcomeValue);
  +                  if (outcome==null) outcome = navigation.getAnyOutcome();
                  }
                  
  -               if (caze!=null)
  +               if (outcome!=null)
                  {
  -                  caze.getConversationControl().beginOrEndConversation();
  -                  caze.getNavigationHandler().navigate(context);
  +                  outcome.getConversationControl().beginOrEndConversation();
  +                  outcome.getNavigationHandler().navigate(context);
                     return true;
                  }
                  
  @@ -412,7 +416,7 @@
         Map<String, Object> parameters = new HashMap<String, Object>();
         for ( Page page: getPageStack(viewId) )
         {
  -         for ( Page.Param pageParameter: page.getPageParameters() )
  +         for ( Param pageParameter: page.getPageParameters() )
            {
               ValueBinding valueBinding = pageParameter.getValueBinding();
               Object value;
  @@ -446,7 +450,7 @@
         Map<String, Object> parameters = new HashMap<String, Object>();
         for ( Page page: getPageStack(viewId) )
         {
  -         for ( Page.Param pageParameter: page.getPageParameters() )
  +         for ( Param pageParameter: page.getPageParameters() )
            {
               if ( !overridden.contains( pageParameter.getName() ) )
               {
  @@ -465,7 +469,7 @@
       * Get the current value of a page parameter, looking in the page context
       * if there is no value binding
       */
  -   private Object getPageParameterValue(FacesContext facesContext, Page.Param pageParameter)
  +   private Object getPageParameterValue(FacesContext facesContext, Param pageParameter)
      {
         ValueBinding valueBinding = pageParameter.getValueBinding();
         if (valueBinding==null)
  @@ -474,35 +478,7 @@
         }
         else
         {
  -         return getParameterValue(facesContext, pageParameter);
  -      }
  -   }
  -
  -   /**
  -    * Get the current value of a page or redirection parameter
  -    */
  -   private static Object getParameterValue(FacesContext facesContext, Page.Param pageParameter)
  -   {
  -      Object value = pageParameter.getValueBinding().getValue();
  -      if (value==null)
  -      {
  -         return null;
  -      }
  -      else
  -      {
  -         Converter converter = null;
  -         try
  -         {
  -            converter = pageParameter.getConverter();
  -         }
  -         catch (RuntimeException re)
  -         {
  -            //YUCK! due to bad JSF/MyFaces error handling
  -            return null;
  -         }
  -         
  -         return converter==null ? 
  -                  value : converter.getAsString( facesContext, facesContext.getViewRoot(), value );
  +         return pageParameter.getValueFromModel(facesContext);
         }
      }
      
  @@ -515,35 +491,12 @@
         Map<String, String[]> requestParameters = Parameters.getRequestParameters();
         for ( Page page: getPageStack(viewId) )
         {
  -         for ( Page.Param pageParameter: page.getPageParameters() )
  -         {  
  -            
  -            String[] parameterValues = requestParameters.get(pageParameter.getName());
  -            if (parameterValues==null || parameterValues.length==0)
  -            {
  -               continue;
  -            }
  -            if (parameterValues.length>1)
  +         for ( Param pageParameter: page.getPageParameters() )
               {
  -               throw new IllegalArgumentException("page parameter may not be multi-valued: " + pageParameter.getName());
  -            }         
  -            String stringValue = parameterValues[0];
      
  -            Converter converter;
  -            try
  -            {
  -               converter = pageParameter.getConverter();
  -            }
  -            catch (RuntimeException re)
  +            Object value = pageParameter.getValueFromRequest(facesContext, requestParameters);
  +            if (value!=null)
               {
  -               //YUCK! due to bad JSF/MyFaces error handling
  -               continue;
  -            }
  -            
  -            Object value = converter==null ? 
  -                  stringValue :
  -                  converter.getAsObject( facesContext, facesContext.getViewRoot(), stringValue );
  -
               ValueBinding valueBinding = pageParameter.getValueBinding();
               if (valueBinding==null)
               {
  @@ -556,6 +509,7 @@
            }
         }
      }
  +   }
   
      /**
       * Apply any page parameters passed as view root attributes to the model.
  @@ -565,7 +519,7 @@
         String viewId = facesContext.getViewRoot().getViewId();
         for ( Page page: getPageStack(viewId) )
         {
  -         for ( Page.Param pageParameter: page.getPageParameters() )
  +         for ( Param pageParameter: page.getPageParameters() )
            {         
               ValueBinding valueBinding = pageParameter.getValueBinding();
               if (valueBinding!=null)
  @@ -731,7 +685,7 @@
         List<Element> children = element.elements("param");
         for (Element param: children)
         {
  -         page.getPageParameters().add( parsePageParameter(param) );
  +         page.getPageParameters().add( parseParam(param) );
         }
         
         List<Element> moreChildren = element.elements("action-navigation");
  @@ -824,7 +778,7 @@
       */
      private static void parseActionNavigation(Page entry, Element element)
      {
  -      Page.ActionNavigation navigation = new Page.ActionNavigation(); 
  +      ActionNavigation navigation = new ActionNavigation(); 
         String outcomeExpression = element.attributeValue("outcome");
         if (outcomeExpression!=null)
         {
  @@ -833,7 +787,7 @@
         List<Element> cases = element.elements("outcome");
         for (Element childElement: cases)
         {
  -         Page.Outcome caze = parseOutcome(childElement);
  +         Outcome caze = parseOutcome(childElement);
            String value = childElement.attributeValue("value");
            if (value==null)
            {
  @@ -866,7 +820,7 @@
      /**
       * Parse param
       */
  -   private static Page.Param parsePageParameter(Element element)
  +   private static Param parseParam(Element element)
      {
         String valueExpression = element.attributeValue("value");
         String name = element.attributeValue("name");
  @@ -878,7 +832,7 @@
            }
            name = valueExpression.substring(2, valueExpression.length()-1);
         }
  -      Page.Param param = new Page.Param(name);
  +      Param param = new Param(name);
         if (valueExpression!=null)
         {
            param.setValueBinding(Expressions.instance().createValueBinding(valueExpression));
  @@ -895,45 +849,30 @@
      /**
       * parse outcome, any-outcome, null-outcome
       */
  -   private static Page.Outcome parseOutcome(Element element)
  +   private static Outcome parseOutcome(Element element)
      {
  -      Page.Outcome caze = new Page.Outcome();
  -      parseConversationControl( element, caze.getConversationControl() );
  +      Outcome outcome = new Outcome();
  +      parseConversationControl( element, outcome.getConversationControl() );
         
         Element render = element.element("render");
         if (render!=null)
         {
            final String viewId = render.attributeValue("view-id");
  -         caze.setNavigationHandler(new Page.NavigationHandler() {
  -            public void navigate(FacesContext context)
  -            {
  -               render(viewId);
  -            }
  -         });
  +         outcome.setNavigationHandler( new RenderNavigationHandler(viewId) );
         }
         Element redirect = element.element("redirect");
         if (redirect!=null)
         {
            List<Element> children = redirect.elements("param");
  -         final List<Param> pageParameters = new ArrayList<Param>();
  +         final List<Param> params = new ArrayList<Param>();
            for (Element child: children)
            {
  -            pageParameters.add( parsePageParameter(child) );
  +            params.add( parseParam(child) );
            }
            final String viewId = redirect.attributeValue("view-id");
  -         caze.setNavigationHandler(new Page.NavigationHandler() {
  -            public void navigate(FacesContext context)
  -            {
  -               Map<String, Object> parameters = new HashMap<String, Object>();
  -               for ( Param pageParameter: pageParameters )
  -               {
  -                  parameters.put( pageParameter.getName(), getParameterValue(context, pageParameter) );
  -               }
  -               redirect(viewId, parameters);
  -            }
  -         });
  +         outcome.setNavigationHandler( new RedirectNavigationHandler(viewId, params) );
         }
  -      return caze;
  +      return outcome;
      }
   
   }
  
  
  



More information about the jboss-cvs-commits mailing list