[jboss-cvs] jboss-seam/src/main/org/jboss/seam/pages ...
Gavin King
gavin.king at jboss.com
Mon Dec 18 19:40:41 EST 2006
User: gavin
Date: 06/12/18 19:40:41
Modified: src/main/org/jboss/seam/pages ActionNavigation.java
NavigationHandler.java Outcome.java Page.java
RedirectNavigationHandler.java
RenderNavigationHandler.java
Added: src/main/org/jboss/seam/pages Input.java
Output.java Put.java
Log:
in and out in pages.xml
Revision Changes Path
1.3 +26 -0 jboss-seam/src/main/org/jboss/seam/pages/ActionNavigation.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ActionNavigation.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/pages/ActionNavigation.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- ActionNavigation.java 18 Dec 2006 15:38:49 -0000 1.2
+++ ActionNavigation.java 19 Dec 2006 00:40:41 -0000 1.3
@@ -6,6 +6,8 @@
import java.util.ArrayList;
import java.util.List;
+import javax.faces.context.FacesContext;
+
import org.jboss.seam.core.Expressions.ValueBinding;
public final class ActionNavigation
@@ -39,4 +41,28 @@
this.outcome = outcome;
}
+ public boolean navigate(FacesContext context, final String actionOutcomeValue)
+ {
+ String outcomeValue;
+ if ( getOutcomeValueBinding()==null )
+ {
+ outcomeValue = actionOutcomeValue;
+ }
+ else
+ {
+ Object value = getOutcomeValueBinding().getValue();
+ outcomeValue = value==null ? null : value.toString();
+ }
+
+ for ( Outcome outcome: getOutcomes() )
+ {
+ if ( outcome.matches(outcomeValue) )
+ {
+ return outcome.execute(context);
+ }
+ }
+
+ return getOutcome().execute(context);
+ }
+
}
\ No newline at end of file
1.2 +1 -1 jboss-seam/src/main/org/jboss/seam/pages/NavigationHandler.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NavigationHandler.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/pages/NavigationHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- NavigationHandler.java 17 Dec 2006 19:46:41 -0000 1.1
+++ NavigationHandler.java 19 Dec 2006 00:40:41 -0000 1.2
@@ -9,5 +9,5 @@
public abstract class NavigationHandler extends Navigator
{
- public abstract void navigate(FacesContext context);
+ public abstract boolean navigate(FacesContext context);
}
\ No newline at end of file
1.3 +20 -1 jboss-seam/src/main/org/jboss/seam/pages/Outcome.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Outcome.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/pages/Outcome.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- Outcome.java 18 Dec 2006 15:38:49 -0000 1.2
+++ Outcome.java 19 Dec 2006 00:40:41 -0000 1.3
@@ -3,6 +3,9 @@
*/
package org.jboss.seam.pages;
+import java.util.ArrayList;
+import java.util.List;
+
import javax.faces.context.FacesContext;
import org.jboss.seam.core.Expressions.ValueBinding;
@@ -11,10 +14,14 @@
{
private String value;
private ValueBinding expression;
+ private List<Output> outputs = new ArrayList<Output>();
private ConversationControl conversationControl = new ConversationControl();
private NavigationHandler navigationHandler = new NavigationHandler() {
@Override
- public void navigate(FacesContext context) {}
+ public boolean navigate(FacesContext context)
+ {
+ return false;
+ }
};
public boolean matches(String actualValue)
@@ -58,4 +65,16 @@
{
this.value = value;
}
+
+ public List<Output> getOutputs()
+ {
+ return outputs;
+ }
+
+ public boolean execute(FacesContext context)
+ {
+ getConversationControl().beginOrEndConversation();
+ for ( Output output: getOutputs() ) output.out();
+ return getNavigationHandler().navigate(context);
+ }
}
\ No newline at end of file
1.3 +46 -0 jboss-seam/src/main/org/jboss/seam/pages/Page.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Page.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/pages/Page.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- Page.java 18 Dec 2006 16:50:31 -0000 1.2
+++ Page.java 19 Dec 2006 00:40:41 -0000 1.3
@@ -6,8 +6,11 @@
import java.util.Map;
import java.util.MissingResourceException;
+import javax.faces.context.FacesContext;
+
import org.jboss.seam.core.Interpolator;
import org.jboss.seam.core.Locale;
+import org.jboss.seam.core.Pages;
/**
* Metadata about page actions, page parameters, action navigation,
@@ -22,6 +25,7 @@
private String resourceBundleName;
private boolean switchEnabled = true;
private List<Param> parameters = new ArrayList<Param>();
+ private List<Input> inputs = new ArrayList<Input>();
private List<Action> actions = new ArrayList<Action>();
private Map<String, ActionNavigation> navigations = new HashMap<String, ActionNavigation>();
private ActionNavigation defaultNavigation;
@@ -176,4 +180,46 @@
return actions;
}
+ /**
+ * Call page actions, in order they appear in XML, and
+ * handle conversation begin/end
+ */
+ public boolean enter(FacesContext facesContext)
+ {
+ boolean result = false;
+
+ getConversationControl().beginOrEndConversation();
+
+ for ( Input in: getInputs() ) in.in();
+
+ for ( Action action: getActions() )
+ {
+ if ( action.isExecutable() )
+ {
+ String outcome = action.getOutcome();
+ String fromAction = outcome;
+
+ if (outcome==null)
+ {
+ fromAction = action.getMethodBinding().getExpressionString();
+ result = true;
+ outcome = Pages.toString( action.getMethodBinding().invoke() );
+ Pages.handleOutcome(facesContext, outcome, fromAction);
+ }
+ else
+ {
+ Pages.handleOutcome(facesContext, outcome, fromAction);
+ }
+ }
+ }
+
+ return result;
+
+ }
+
+ public List<Input> getInputs()
+ {
+ return inputs;
+ }
+
}
\ No newline at end of file
1.2 +2 -1 jboss-seam/src/main/org/jboss/seam/pages/RedirectNavigationHandler.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: RedirectNavigationHandler.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/pages/RedirectNavigationHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- RedirectNavigationHandler.java 17 Dec 2006 19:46:41 -0000 1.1
+++ RedirectNavigationHandler.java 19 Dec 2006 00:40:41 -0000 1.2
@@ -21,7 +21,7 @@
}
@Override
- public void navigate(FacesContext context)
+ public boolean navigate(FacesContext context)
{
Map<String, Object> parameters = new HashMap<String, Object>();
for ( Param pageParameter: params )
@@ -29,5 +29,6 @@
parameters.put( pageParameter.getName(), pageParameter.getValueFromModel(context) );
}
redirect(viewId, parameters);
+ return true;
}
}
\ No newline at end of file
1.2 +2 -1 jboss-seam/src/main/org/jboss/seam/pages/RenderNavigationHandler.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: RenderNavigationHandler.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/pages/RenderNavigationHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- RenderNavigationHandler.java 17 Dec 2006 19:46:41 -0000 1.1
+++ RenderNavigationHandler.java 19 Dec 2006 00:40:41 -0000 1.2
@@ -15,8 +15,9 @@
}
@Override
- public void navigate(FacesContext context)
+ public boolean navigate(FacesContext context)
{
render(viewId);
+ return true;
}
}
\ No newline at end of file
1.1 date: 2006/12/19 00:40:41; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/pages/Input.java
Index: Input.java
===================================================================
package org.jboss.seam.pages;
import org.jboss.seam.Component;
public class Input extends Put
{
public void in()
{
Object object = getScope()==null ?
Component.getInstance( getName() ) :
getScope().getContext().get( getName() );
getValue().setValue( object );
}
}
1.1 date: 2006/12/19 00:40:41; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/pages/Output.java
Index: Output.java
===================================================================
package org.jboss.seam.pages;
public class Output extends Put
{
public void out()
{
getScope().getContext().set( getName(), getValue().getValue() );
}
}
1.1 date: 2006/12/19 00:40:41; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/pages/Put.java
Index: Put.java
===================================================================
package org.jboss.seam.pages;
import org.jboss.seam.ScopeType;
import org.jboss.seam.core.Expressions.ValueBinding;
public class Put
{
private String name;
private ScopeType scope;
private ValueBinding value;
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public ScopeType getScope()
{
return scope;
}
public void setScope(ScopeType scope)
{
this.scope = scope;
}
public ValueBinding getValue()
{
return value;
}
public void setValue(ValueBinding value)
{
this.value = value;
}
}
More information about the jboss-cvs-commits
mailing list