org.apache.myfaces.trinidad.model
Class ProcessUtils

java.lang.Object
  extended by org.apache.myfaces.trinidad.model.ProcessUtils

public class ProcessUtils
extends Object

There are two common scenarios for processes, "Plus One" and "Max Visited" which are explained below.

A node in a process should be readOnly if that step of the process is not reachable from the current step.

A node in a process should be immediate if the values in the current step don't need to be validated.


Constructor Summary
ProcessUtils()
           
 
Method Summary
static void clearMaxPath(String maxPathKey)
           
static Object getMaxVisitedRowKey(MenuModel model, String maxPathKey)
          Get the rowKey of the max visited node in the respective process.
static boolean isImmediate(MenuModel model, boolean defaultReturnValue)
           Determines immediate for a "plus one" process.
static boolean isImmediate(MenuModel model, Object maxVisitedRowKey, boolean defaultReturnValue)
           Determines immediate for a "max visited" process.
static boolean isReadOnly(MenuModel model, boolean defaultReturnValue)
           Determines readOnly for a "plus one" process.
static boolean isReadOnly(MenuModel model, Object maxVisitedRowKey, boolean defaultReturnValue)
           Determines readOnly for a "max visited" process.
static boolean isVisited(MenuModel model, boolean defaultReturnValue)
          For the Plus One case, a stop is considered visited if, - it's before the current or, - is the current stop itself
static boolean isVisited(MenuModel model, Object maxVisitedRowKey, boolean defaultReturnValue)
          For the Max Visited case, a stop is considered visited if - a stop is before the active stop - or is the active stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessUtils

public ProcessUtils()
Method Detail

isImmediate

public static boolean isImmediate(MenuModel model,
                                  boolean defaultReturnValue)

Determines immediate for a "plus one" process. Immediate will be true for any previous step, and false otherwise. For example if the user is on step 5 and goes back to step 2, the user will have to come back to step 5 again, so the fields on page 5 don't need to be validated when going back to steps 1,2,3,4, but should be validated when going to step 6.

Parameters:
model - the model instance to use. When the model is passed in a call to model.getPath should return the path for the "current" node.
defaultReturnValue - if the current and focus nodes aren't siblings in the tree, this value will be returned.
Returns:
whether or not the current node should be immediate.

isReadOnly

public static boolean isReadOnly(MenuModel model,
                                 boolean defaultReturnValue)

Determines readOnly for a "plus one" process. ReadOnly will be true for any step past the next available step

Parameters:
model - the model instance to use. When the model is passed in a call to model.getPath should return the path for the "current" node.
defaultReturnValue - if the current and focus nodes aren't siblings in the tree, this value will be returned.
Returns:
whether or not the current node should be immediate.

isImmediate

public static boolean isImmediate(MenuModel model,
                                  Object maxVisitedRowKey,
                                  boolean defaultReturnValue)

Determines immediate for a "max visited" process. When the current step and the max step are the same immediate will be true for any previous step, and false otherwise. If the current step is before the max step, immediate will be false.

Parameters:
model - the model instance to use. When the model is passed in a call to model.getRowKey should return the rowKey for the "current" node.
maxVisitedRowKey - the rowKey to use to determine the max node
defaultReturnValue - if the current, max, and focus nodes aren't siblings in the tree, this value will be returned.
Returns:
whether or not the current node should be immediate.

isReadOnly

public static boolean isReadOnly(MenuModel model,
                                 Object maxVisitedRowKey,
                                 boolean defaultReturnValue)

Determines readOnly for a "max visited" process. When the current step and the max step are the same, readOnly will be true for any step past the next available step. If the current step is before the max step, then readOnly will be true for any step past the max step.

Parameters:
model - the model instance to use. When the model is passed in a call to model.getRowKey should return the rowKey for the "current" node.
maxVisitedRowKey - the rowKey to use to determine the max node
defaultReturnValue - if the current, max, and focus nodes aren't siblings in the tree, this value will be returned.
Returns:
whether or not the current node should be immediate.

isVisited

public static boolean isVisited(MenuModel model,
                                boolean defaultReturnValue)
For the Plus One case, a stop is considered visited if, - it's before the current or, - is the current stop itself

Parameters:
model - the menuModel instance to use. When the model is passed in, a call to model.getRowKey should return the rowKey for the "current" node.
defaultReturnValue - if the current and focus nodes aren't siblings in the tree, this value will be returned.
Returns:
whether or not the current node has been visited.

isVisited

public static boolean isVisited(MenuModel model,
                                Object maxVisitedRowKey,
                                boolean defaultReturnValue)
For the Max Visited case, a stop is considered visited if - a stop is before the active stop - or is the active stop

Parameters:
model - the menuModel instance to use. When the model is passed in, a call to model.getRowKey should return the rowKey for the "current" node.
maxVisitedRowKey - the rowKey to use to determine the max visited node
defaultReturnValue - if the current, maxVisited and focus nodes aren't siblings in the tree, this value will be returned.
Returns:
whether or not the current node has been visited.

getMaxVisitedRowKey

public static Object getMaxVisitedRowKey(MenuModel model,
                                         String maxPathKey)
Get the rowKey of the max visited node in the respective process. If null set maxVisitedRowKey to be the focus rowKey. If set but the focus rowKey is after maxVisitedRowKey, set maxVisitedRowKey to the focus rowKey.

Parameters:
model - the model instance to use. When the model is passed in a call to model.getRowKey should return the key for the "current" node.
maxPathKey - this key is used to store the maxVisitedRowKey in both the session and request map.
Returns:
the rowKey to the "max visited" node.

clearMaxPath

public static void clearMaxPath(String maxPathKey)


Copyright © 2001-2012 The Apache Software Foundation. All Rights Reserved.