How to Create the Train Model

Working with Navigation Components 18-45 managed-property managed-property property-nameoutcomeproperty-name valueguide.trainvalue managed-property managed-property property-namelabelproperty-name valueFirst Stepvalue managed-property managed-property property-namemodelproperty-name valuetrainMenuModelvalue managed-property managed-bean -- Second train stop -- managed-bean managed-bean-nametrain2managed-bean-name managed-bean-classproject1.DemoTrainStopModelmanaged-bean-class managed-bean-scopenonemanaged-bean-scope managed-property property-nameviewIdproperty-name valuetrain2.jspxvalue managed-property managed-property property-nameoutcomeproperty-name valueguide.train2value managed-property managed-property property-namelabelproperty-name valueSecond Stepvalue managed-property managed-property property-namemodelproperty-name valuetrainMenuModelvalue managed-property managed-bean -- And so on -- . . . The managed properties set the values to the train stop model object the class created in Step 1 in Section 18.8.1, How to Create the Train Model . The viewId value is the path and file name to the page that is navigated to when the user clicks a train stop. The outcome property value is the action outcome string that matches a JSF navigation case. The default JSF ActionListener mechanism is used to choose the page associated with the train stop as the view to navigate to when the train stop is selected. The label property value is the train stop label text that displays beneath the train stop image. The value can be static or an EL expression that evaluates to a string in a resource bundle. The model property value is the managed bean name of the train model see Example 18–25 . 18-46 Web User Interface Developers Guide for Oracle Application Development Framework If a train stop has subprocess train children, the managed bean configuration should also include the property for example, children that lists the managed bean names of the subprocess train stops in value expressions for example, {train4a}, as shown in Example 18–22 . Example 18–22 Managed Bean for a Train Stop with Subprocess train Children managed-bean managed-bean-nametrain4managed-bean-name managed-bean-classproject1.DemoTrainStopModelmanaged-bean-class managed-bean-scopenonemanaged-bean-scope managed-property property-nameviewIdproperty-name valuetrain4.jspxvalue managed-property managed-property property-nameoutcomeproperty-name valueguide.train4value managed-property managed-property property-namelabelproperty-name valueFourth Stepvalue managed-property managed-property property-namechildrenproperty-name list-entries value-classproject1.DemoTrainStopModelvalue-class value{train4a}value value{train4b}value value{train4c}value list-entries managed-property managed-property property-namemodelproperty-name valuetrainMenuModelvalue managed-property managed-bean 2. Configure a managed bean that is an instance of an ArrayList object to create the list of train stops to pass into the train tree model. Example 18–23 shows sample managed bean code for creating the train stop list. Example 18–23 Managed Bean for Train List managed-bean managed-bean-nametrainListmanaged-bean-name managed-bean-class java.util.ArrayList managed-bean-class managed-bean-scope none managed-bean-scope list-entries value-classproject1.DemoTrainStopModelvalue-class value{train1}value value{train2}value value{train3}value value{train4}value value{train5}value Working with Navigation Components 18-47 list-entries managed-bean The list-entries element contains the managed bean names for the train stops excluding subprocess train stops in value expressions for example, {train1}, listed in the order that the stops should appear on the train. 3. Configure a managed bean to create the train tree model from the train list. The train tree model wraps the entire train list, including any subprocess train lists. The train model managed bean should be instantiated with a childProperty value that is the same as the property name that represents the list of subprocess train children see Example 18–22 . Example 18–24 Managed Bean for Train Tree Model managed-bean managed-bean-nametrainTreemanaged-bean-name managed-bean-class org.apache.myfaces.trinidad.model.ChildPropertyTreeModel managed-bean-class managed-bean-scopenonemanaged-bean-scope managed-property property-namechildPropertyproperty-name valuechildrenvalue managed-property managed-property property-namewrappedDataproperty-name value{trainList}value managed-property managed-bean The childProperty property defines the property name to use to get the child list entries of each train stop that has a subprocess train. The wrappedData property value is the train list instance to wrap, created by the managed bean in Step 2. 4. Configure a managed bean to create the train model from the train tree model. This is the bean to which the train component on each page is bound. The train model wraps the train tree model. The train model managed bean should be instantiated with a viewIdProperty value that is the same as the property name that represents the pages associated with the train stops. Example 18–25 shows sample managed bean code for a train model. Example 18–25 Managed Bean for Train Model managed-bean managed-bean-nametrainMenuModelmanaged-bean-name managed-bean-class org.apache.myfaces.trinidad.model.ProcessMenuModel managed-bean-class managed-bean-scopesessionmanaged-bean-scope managed-property property-nameviewIdPropertyproperty-name valueviewIdvalue managed-property managed-property property-namewrappedDataproperty-name value{trainTree}value