[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...
Gavin King
gavin.king at jboss.com
Fri Dec 15 09:30:00 EST 2006
User: gavin
Date: 06/12/15 09:30:00
Modified: src/main/org/jboss/seam/core Manager.java Pageflow.java
Pages.java
Log:
javadoc
allow use of customized view ids in a pageflow
Revision Changes Path
1.125 +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.124
retrieving revision 1.125
diff -u -b -r1.124 -r1.125
--- Manager.java 13 Dec 2006 10:17:10 -0000 1.124
+++ Manager.java 15 Dec 2006 14:30:00 -0000 1.125
@@ -42,7 +42,7 @@
*
* @author Gavin King
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.124 $
+ * @version $Revision: 1.125 $
*/
@Scope(ScopeType.EVENT)
@Name("org.jboss.seam.core.manager")
@@ -1008,7 +1008,7 @@
//use stuff from the pageflow definition
if ( pageflowPage.isSwitchEnabled() )
{
- conversation.setViewId( pageflowPage.getViewId() );
+ conversation.setViewId( Pageflow.instance().getPageViewId() );
}
if ( pageflowPage.hasDescription() )
{
1.46 +90 -8 jboss-seam/src/main/org/jboss/seam/core/Pageflow.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Pageflow.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Pageflow.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -b -r1.45 -r1.46
--- Pageflow.java 24 Nov 2006 23:15:17 -0000 1.45
+++ Pageflow.java 15 Dec 2006 14:30:00 -0000 1.46
@@ -74,11 +74,19 @@
return (Pageflow) Component.getInstance(Pageflow.class, ScopeType.CONVERSATION);
}
+ /**
+ * Get the current counter value, used for detecting
+ * illegal use of the backbutton.
+ */
public int getPageflowCounter()
{
return counter;
}
+ /**
+ * Check that the current state of the pageflow matches
+ * what is expected by the faces request.
+ */
public void validatePageflow()
{
if ( processInstance!=null )
@@ -119,6 +127,11 @@
context.renderResponse();
}
+ /**
+ * Add a message to indicate that illegal navigation
+ * occurred. May be overridden by user to perform
+ * special processing.
+ */
protected void illegalNavigation()
{
FacesMessages.instance().addFromResourceBundle(
@@ -128,6 +141,9 @@
);
}
+ /**
+ * Get the current Node of the pageflow.
+ */
public Node getNode()
{
if (processInstance==null) return null;
@@ -140,6 +156,11 @@
return node;
}
+ /**
+ * Reposition the pageflow at the named node.
+ *
+ * @param nodeName the name of a node
+ */
public void reposition(String nodeName)
{
if (processInstance==null)
@@ -158,6 +179,9 @@
setDirty();
}
+ /**
+ * Get the current Page of the pageflow.
+ */
public Page getPage()
{
Node node = getNode();
@@ -168,24 +192,68 @@
return (Page) node;
}
- private void navigate(FacesContext context)
+ /**
+ * Navigate to the current page.
+ */
+ protected void navigate(FacesContext context)
{
Page page = getPage();
if ( !page.isRedirect() )
{
- UIViewRoot viewRoot = context.getApplication().getViewHandler()
- .createView( context, page.getViewId() );
- context.setViewRoot(viewRoot);
+ render(context, page);
}
else
{
- Manager.instance().redirect( page.getViewId() );
+ redirect(page);
}
counter++;
setDirty();
}
+ /**
+ * Redirect to the Page.
+ */
+ protected void redirect(Page page)
+ {
+ Manager.instance().redirect( getViewId(page) );
+ }
+
+ /**
+ * Proceed to render the Page.
+ */
+ protected void render(FacesContext context, Page page)
+ {
+ UIViewRoot viewRoot = context.getApplication().getViewHandler()
+ .createView( context, getViewId(page) );
+ context.setViewRoot(viewRoot);
+ }
+
+ /**
+ * Allows the user to extend this class and use some
+ * logical naming of pages other than the JSF view id
+ * in their pageflow.
+ *
+ * @param page the Page object
+ * @return a JSF view id
+ */
+ protected String getViewId(Page page)
+ {
+ return page.getViewId();
+ }
+
+ /**
+ * Get the JSF view id of the current page in the
+ * pageflow.
+ */
+ public String getPageViewId()
+ {
+ return getViewId( getPage() );
+ }
+
+ /**
+ * Does the current node have a default transition?
+ */
public boolean hasDefaultTransition()
{
//we don't use jBPM's default transition,
@@ -204,6 +272,10 @@
getNode().getLeavingTransition(outcome)!=null;
}
+ /**
+ * Given the JSF action outcome, perform navigation according
+ * to the current pageflow.
+ */
public void navigate(FacesContext context, String outcome) {
if ( isNullOutcome(outcome) )
{
@@ -230,6 +302,12 @@
}
}
+ /**
+ * Process events defined in the pageflow.
+ *
+ * @param type one of: "process-validations", "update-model-values",
+ * "invoke-application", "render-response"
+ */
public void processEvents(String type)
{
Event event = getNode().getEvent(type);
@@ -249,6 +327,11 @@
}
}
+ /**
+ * Begin executing a pageflow.
+ *
+ * @param pageflowDefinitionName the name of the pageflow definition
+ */
public void begin(String pageflowDefinitionName)
{
if ( log.isDebugEnabled() )
@@ -291,8 +374,7 @@
Node node = pageflowProcessDefinition.getNode(pageflowNodeName);
if (node!=null && node instanceof Page)
{
- Page page = (Page) node;
- return page.getNoConversationViewId();
+ return ( (Page) node ).getNoConversationViewId();
}
else
{
@@ -300,7 +382,7 @@
}
}
- private ProcessDefinition getPageflowProcessDefinition(String pageflowName)
+ protected ProcessDefinition getPageflowProcessDefinition(String pageflowName)
{
ProcessDefinition pageflowProcessDefinition = Jbpm.instance().getPageflowProcessDefinition(pageflowName);
if (pageflowProcessDefinition==null)
1.58 +47 -0 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.57
retrieving revision 1.58
diff -u -b -r1.57 -r1.58
--- Pages.java 10 Dec 2006 14:22:28 -0000 1.57
+++ Pages.java 15 Dec 2006 14:30:00 -0000 1.58
@@ -221,6 +221,11 @@
}
}
+ /**
+ * Get the Page object for the given view id.
+ *
+ * @param viewId a JSF view id
+ */
public Page getPage(String viewId)
{
if (viewId==null)
@@ -281,6 +286,12 @@
return loc<0 ? null : viewId.substring(0, loc) + suffix;
}
+ /**
+ * Get the stack of Page objects, from least specific to
+ * most specific, that match the given view id.
+ *
+ * @param viewId a JSF view id
+ */
protected List<Page> getPageStack(String viewId)
{
List<Page> stack = pageStacksByViewId.get(viewId);
@@ -373,6 +384,9 @@
return (Pages) Component.getInstance(Pages.class, ScopeType.APPLICATION);
}
+ /**
+ * Call the action requested by s:link or s:button.
+ */
public static boolean callAction(FacesContext facesContext)
{
//TODO: refactor with Pages.instance().callAction()!!
@@ -422,11 +436,25 @@
return result;
}
+ /**
+ * Get the values of any page parameters by evaluating the value bindings
+ * against the model and converting to String.
+ *
+ * @param viewId the JSF view id
+ * @return a map of page parameter name to String value
+ */
public Map<String, Object> getConvertedParameters(FacesContext facesContext, String viewId)
{
return getConvertedParameters(facesContext, viewId, Collections.EMPTY_SET);
}
+ /**
+ * Get the values of any page parameters by evaluating the value bindings
+ * against the model.
+ *
+ * @param viewId the JSF view id
+ * @return a map of page parameter name to value
+ */
protected Map<String, Object> getParameters(String viewId)
{
Map<String, Object> parameters = new HashMap<String, Object>();
@@ -453,6 +481,14 @@
return parameters;
}
+ /**
+ * Get the values of any page parameters by evaluating the value bindings
+ * against the model and converting to String.
+ *
+ * @param viewId the JSF view id
+ * @param overridden override certain parameter values
+ * @return a map of page parameter name to String value
+ */
public Map<String, Object> getConvertedParameters(FacesContext facesContext, String viewId, Set<String> overridden)
{
Map<String, Object> parameters = new HashMap<String, Object>();
@@ -497,6 +533,9 @@
return parameters;
}
+ /**
+ * Apply any page parameters passed as parameter values to the model.
+ */
public void applyRequestParameterValues(FacesContext facesContext)
{
String viewId = facesContext.getViewRoot().getViewId();
@@ -545,6 +584,9 @@
}
}
+ /**
+ * Apply any page parameters passed as view root attributes to the model.
+ */
public void applyViewRootValues(FacesContext facesContext)
{
String viewId = facesContext.getViewRoot().getViewId();
@@ -565,6 +607,11 @@
}
}
+ /**
+ * The global setting for no-conversation-viewid.
+ *
+ * @return a JSF view id
+ */
public String getNoConversationViewId()
{
return noConversationViewId;
More information about the jboss-cvs-commits
mailing list