You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Zigc Junk <zi...@gmail.com> on 2008/07/31 23:23:03 UTC

Re: How can I create a session scoped Trinidad menu model

Did u try to change from request to session? Since your bean is
request scoped, every request will create a new instance of the bean,
so does its property.

regard

Bill

On Thu, Jul 31, 2008 at 4:05 PM, Silverman, Glenn <GS...@dylt.com> wrote:
> I need a session-scoped menu model but the documentation says I can't, and
> that creates a problem
> whenever I click on a button to do something when I'm not on the first tab
> of the menu. Here's my code...
> I have a trinidad switcher control managed by a commandNavigationItem
> control.
>
>                         <tr:navigationPane id="navPaneA" level="1"
> value="#{root_menu}" var="foo">
>                                 <f:facet name="nodeStamp">
>                                         <tr:commandNavigationItem
> id="navItemA" text="#{foo.label}"
>                                                 action="#{foo.doAction}"/>
>                                 </f:facet>
>                         </tr:navigationPane>
>
>                         <tr:switcher facetName="#{root_menu.navLabel}"
> defaultFacet="Messages" >
>                                 <f:facet name="Messages">
>                                 <tr:panelGroupLayout layout="vertical">
>                                                 <jsp:include
> page="../editors/errormessages.jspx"/>
>                                         </tr:panelGroupLayout>
>                                 </f:facet>
>                                 <f:facet name="Help Text">
>                                 <tr:panelGroupLayout layout="vertical">
>                                                 <jsp:include
> page="../editors/help.jspx"/>
>                                         </tr:panelGroupLayout>
>                                 </f:facet>
>                         <f:facet name="Buttons">
>                            <tr:panelGroupLayout layout="vertical">
>                                                 <jsp:include
> page="../editors/buttons.jspx"/>
>                                         </tr:panelGroupLayout>
>                                 </f:facet>
>                                 <f:facet name="Sounds">
>                                 <tr:panelGroupLayout layout="vertical">
>                                                 <jsp:include
> page="../editors/sounds.jspx"/>
>                                         </tr:panelGroupLayout>
>                                 </f:facet>
>                         </tr:switcher>
>
> And a menu model:
>
>         <menu xmlns="http://myfaces.apache.org/trinidad/menu">
>                 <groupNode id="msgs" idref="message" label="Error Messages"
> defaultFocustPath="true">
>                         <itemNode id="message" label="Messages"
> action="goToMessages"
>                                 focusViewId="/index.jspx"/>
>                         <itemNode id="help" label="Help Text"
> action="goToHelp"
>                                 focusViewId="/index.jspx"/>
>                         <itemNode id="button" label="Buttons"
> action="goToButton"
>                                 focusViewId="/index.jspx"/>
>                         <itemNode id="sound" label="Sounds"
> action="goToSound"
>                                 focusViewId="/index.jspx"/>
>                 </groupNode>
>                 <groupNode id="allcodes" label="AllCodes" idref="cat">
>
>                         <itemNode id="cat" label="Categories"
> action="goToCategory"
>                                 focusViewId="/index.jspx" />
>                         <itemNode id="link" label="CodeLinks"
> action="goToLink"
>                                 focusViewId="/index.jspx" />
>                 </groupNode>
>         </menu>
>
> which is defined in faces-config.xml as a managed bean:
>
>       <managed-bean>
>         <managed-bean-name>root_menu</managed-bean-name>
>         <managed-bean-class>com.dylt.bean.MenuModelBean</managed-bean-class>
>         <managed-bean-scope>request</managed-bean-scope>
>         <managed-property>
>               <property-name>source</property-name>
>               <property-class>java.lang.String</property-class>
>               <value>/WEB-INF/menu-metadata.xml</value>
>        </managed-property>
>       </managed-bean>
>
> Here, MenuModelBean just extends XMLMenuModel as follows (This is
> similar to the example in the Trinidad Developer Guide):
>
>         public class MenuModelBean extends XMLMenuModel {
>
>                 public String getGroupLabel(){
>                         List list = getNodesFromFocusPath(false);
>                         return (String)list.get(list.size()-1);
>                 }
>                 public String getNavLabel(){
>                         List list = getNodesFromFocusPath(true);
>                         return (String)list.get(list.size()-1);
>                 }
>         public List getNodesFromFocusPath(boolean itemsOnly){
>         ArrayList focusPath = (ArrayList)this.getFocusRowKey();
>         return getNodesFromFocusPath(focusPath, itemsOnly);
>         }
>
>         public List getNodesFromFocusPath(ArrayList focusPath, boolean
> itemsOnly){
>
>
>               if (focusPath == null || focusPath.size() == 0)
>                 return null;
>
>               // Clone the focusPath cause we remove elements
>               ArrayList fp = (ArrayList) focusPath.clone();
>
>               // List of nodes to return
>               List nodeList = new ArrayList<Object>();
>
>               // Convert String rowkey to int and point to the
>               // node (row) corresponding to this index
>               int targetNodeIdx = (Integer)fp.get(0);
>               TreeModel tree = (TreeModel)this.getWrappedData();
>
>               tree.setRowIndex(targetNodeIdx);
>
>               // Get the node
>               Object node = tree.getRowData();
>               String label = null;
>               if(node instanceof ItemNode){
>                   label= ((ItemNode)node).getLabel();
>                   if(itemsOnly)
>                           nodeList.add(label);
>               }
>               else if (node instanceof GroupNode){
>                   label= ((GroupNode)node).getLabel();
>                   if(!itemsOnly)
>                           nodeList.add(label);
>               }
>
>
>               // Remove the 0th rowkey from the focus path
>               // leaving the remaining focus path
>               fp.remove(0);
>
>               // traverse into children
>               if (   fp.size() > 0
>                   && tree.isContainer()
>                   && !tree.isContainerEmpty()
>                  )
>               {
>                 tree.enterContainer();
>
>                 // get list of nodes in remaining focusPath
>                 List childList = getNodesFromFocusPath(fp, itemsOnly);
>
>                 // Add this list to the nodeList
>                 nodeList.addAll(childList);
>
>                 tree.exitContainer();
>               }
>
>               return nodeList;
>             }
>       )
>
> Here's the problem: If I'm on one of the facet pages other than the first
> one, clicking
> on any command button or link always takes me back to the first facet. If I
> use
> partialSubmit and partialTriggers to try to limit page refresh to a
> particular page
> element, the behavior is even more bizarre. If I click on a tab to change
> facets, the
> first command button or link click works as expected, but any subsequent
> clicks assume
> I am on the first facet page and won't update the facet page I'm on at all.
>
> Here's an example page, the help.jspx in the second facet:
>
>         jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
>                 xmlns:f="http://java.sun.com/jsf/core"
>                 xmlns:tr="http://myfaces.apache.org/trinidad">
>         <jsp:directive.page contentType="text/html;charset=utf-8" />
>                 <f:subview id="helpWrapperA">
>                         <tr:table id="helpTableA" var="hlp"
> value="#{helpBean.list}" partialTriggers="helpEditLink">
>                                 <tr:column headerText="Id">
>                                         <tr:outputText value="#{hlp.helpId}"
> />
>                                 </tr:column>
>                                 <tr:column headerText="Message">
>                                         <tr:commandLink id="helpEditLink"
> text="#{hlp.text}"
>                                                 immediate="true"
> partialSubmit="true">
>                                                 <tr:setActionListener
> from="#{hlp}"
>
> to="#{pageFlowScope.helpDetail}" />
>                                         </tr:commandLink>
>                                 </tr:column>
>                         </tr:table>
>         </f:subview>
>         <tr:separator/>
>         <tr:showDetail undisclosedText="Show Detail" disclosedText="Hide
> Detail">
>                 <f:subview id="helpWrapperB">
>                                 <tr:panelFormLayout rows="2"
>
> partialTriggers=":::helpWrapperA:helpTableA:helpEditLink">
>                                         <tr:outputText value="ID:" />
>                                         <tr:outputText value="Text:" />
>                                         <tr:outputText
> value="#{pageFlowScope.helpDetail.helpId}" />
>                                         <tr:inputText
> value="#{pageFlowScope.helpDetail.text}"/>
>                                 </tr:panelFormLayout>
>                     </f:subview>
>                 </tr:showDetail>
>         </jsp:root>
>
> Could this behavior be the result of the fact that the scope for the menu
> model must be "request" ? If so, then every subsequent
>
> "request" will always go to, or assume I'm on,  the default tab.  How can I
> change this?
>
> Glenn Silverman
>
>

Re: How can I create a session scoped Trinidad menu model

Posted by Andrew Robinson <an...@gmail.com>.
Trinidad doesn't support full page PPR that I know of, at least I
could not get it working when I tried. You can either (1) do it
yourself with a custom view handler or (2) use redirect in the
navigation rules that are using in you menu.

Can any developer speak to why Trinidad doesn't seem to support full
page PPR? I know that there are problems with Trinidad's ppr response
writer not escaping CDATA blocks correctly at the very least.

-Andrew

On Mon, Aug 4, 2008 at 11:08 AM, Silverman, Glenn <GS...@dylt.com> wrote:
> Fine. I don't need it to be in session scope, but then, what about
> the use case I've been wrestling with. In other words, how can
> you use the menu tabs to navigate using a single page and partial
> page rendering. It only works as long as the rendered panels, using
> a switcher or some other controls, don't have any form commands that
> issue requests back to the server.
>
> That's not the way I understand such a common use-case should
> work.
>
> Glenn...
>
> -----Original Message-----
> From: Andrew Robinson [mailto:andrew.rw.robinson@gmail.com]
> Sent: Monday, August 04, 2008 10:02 AM
> To: MyFaces Discussion
> Subject: Re: How can I create a session scoped Trinidad menu model
>
>
> Why do you want it to be session scoped? What advantage would that
> have for you? The architecture is really coded for only one use case,
> so trying to use it outside of how the Oracle developer thought you
> would use it is really ugly. It probably needs a re-write at some
> point.
>
> -Andrew
>
> On Mon, Aug 4, 2008 at 10:40 AM, Silverman, Glenn <GS...@dylt.com> wrote:
>> I'm still in a quandry. I tried using ChildPropertyMenuModel and that turns out
>> to be a nightmare just configuring in faces-config.xml, and, I could not get
>> it to work using the "level" attribute on NavigationPane control to retrieve the children nodes.
>>
>> So, I'm back to trying to get XMLMenuModel to work. Does anyone know why you can't create it in
>> session scope and/or, is there a work-around?
>>
>> Here's simple web app anyone can easily set up that demonstrates the problem.
>>
>> menu-metadata.xml:
>> <menu xmlns="http://myfaces.apache.org/trinidad/menu">
>>  <itemNode id="gin1" label="Global 0"
>>              focusViewId="/index.jspx">
>>    <itemNode id="in1" label="Tab 1" destination="index.jspx"
>>              focusViewId="/index.jspx">
>>    </itemNode>
>>    <itemNode id="in2" label="Tab 2" destination="index.jspx"
>>                focusViewId="/index.jspx"/>
>>  </itemNode>
>>  <itemNode id="gin1" label="Global 1"
>>            destination="index.jspx"
>>            focusViewId="/index.jspx"/>
>>  <itemNode id="gin2" label="Global 2"
>>            destination="index.jspx" focusViewId="/index.jspx"/>
>> </menu>
>>
>>
>> Faces-config.xml:
>> <faces-config
>>    xmlns="http://java.sun.com/xml/ns/javaee"
>>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
>>    version="1.2">
>>  <application>
>>    <!-- Use the Trinidad RenderKit -->
>>    <default-render-kit-id>org.apache.myfaces.trinidad.core</default-render-kit-id>
>>   </application>
>>
>>   <!-- managed bean menu model -->
>>     <managed-bean>
>>       <managed-bean-name>root_menu</managed-bean-name>
>>       <managed-bean-class>org.apache.myfaces.trinidad.model.XMLMenuModel</managed-bean-class>
>>       <managed-bean-scope>request</managed-bean-scope>
>>       <managed-property>
>>         <property-name>source</property-name>
>>         <value>/WEB-INF/menu-metadata.xml</value>
>>       </managed-property>
>>     </managed-bean>
>> </faces-config>
>>
>>
>> Index.jspx
>> <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
>> <jsp:root version="1.2"
>>  xmlns:jsp="http://java.sun.com/JSP/Page"
>>  xmlns:f="http://java.sun.com/jsf/core"
>>  xmlns:tr="http://myfaces.apache.org/trinidad">
>>  <jsp:directive.page contentType="text/html;charset=utf-8"/>
>>  <f:view>
>>    <tr:document title="MenuModel Demo">
>>      <tr:form>
>>       <tr:page var="foo" value="#{root_menu}">
>>          <f:facet name="branding">
>>            <tr:panelGroupLayout layout="vertical">
>>               <tr:outputText value="MenuModel"/>
>>            </tr:panelGroupLayout>
>>          </f:facet>
>>          <tr:panelHorizontalLayout valign="top" >
>>            <f:facet name="separator">
>>                        <tr:spacer width="10" height="1"/>
>>                        </f:facet>
>>           <tr:navigationTree var="foo" value="#{root_menu}">
>>                                <f:facet name="nodeStamp">
>>                                        <tr:commandNavigationItem
>>                                          text="#{foo.label}"
>>                                          action="#{foo.doAction}"/>
>>                              </f:facet>
>>                </tr:navigationTree>
>>                <tr:panelGroupLayout layout="vertical">
>>                            <tr:navigationPane var="foo" value="#{root_menu}" level="1" >
>>                                                <f:facet name="nodeStamp">
>>                                                        <tr:commandNavigationItem
>>                                                          text="#{foo.label}"
>>                                                          action="#{foo.doAction}"/>
>>                                              </f:facet>
>>                            </tr:navigationPane>
>>                    <tr:panelHorizontalLayout valign="top">
>>                        <tr:commandButton id="myButton" text="Ok" actionListener="#{myButton.doSomething}"/>
>>                        <tr:outputText value="#{root_menu.focusRowKey}" />
>>                    </tr:panelHorizontalLayout>
>>                </tr:panelGroupLayout>
>>          </tr:panelHorizontalLayout>
>>        </tr:page>
>>      </tr:form>
>>    </tr:document>
>>  </f:view>
>> </jsp:root>
>>
>>
>> Index.jspx just has a left-side tree pane that uses the menu and a panel layout that uses the level 1 menu
>> items as tabs. The page has a single button that when clicked, shows the focusRowKey of the selected menu
>> item.
>>
>> Clicking the button twice always takes you back to focusRowKey=[0] the first menu item, which in
>> this case is the itemNode, "Global 0", no matter what tab you selected. That's because the menu is
>> in request scope. I've tried everything I can think of to capture the selected node in session and
>> even pageFlowScope. but nothing seems to work.
>>
>> Has anyone been able to solve this issue. If not, then I will have to go back to Ajax4jsf, or some other
>> JSF implementation to use in my apps.
>>
>> Glenn...
>>
>> -----Original Message-----
>> From: Andrew Robinson [mailto:andrew.rw.robinson@gmail.com]
>> Sent: Thursday, July 31, 2008 4:24 PM
>> To: MyFaces Discussion
>> Subject: Re: How can I create a session scoped Trinidad menu model
>>
>>
>> My personal opinion would be to not use it. It really gave me
>> heartburn when I attempted to use it. I would recommend using
>> ChildPropertyMenuModel instead and if you want to use XML, use the
>> commons digester with it. That is just my opinion though.
>>
>> BTW, I think it really is application scoped in practice, as it uses
>> one shared model, so there really isn't any state to save (like in the
>> session). The architecture of it is very odd and a bit broken (you can
>> only have one menu model on a page for example).
>>
>> -Andrew
>>
>> On Thu, Jul 31, 2008 at 3:46 PM, Silverman, Glenn <GS...@dylt.com> wrote:
>>> Are there any examples available of using XMLMenuModel. The
>>> Trinidad demo apps use ProcessMenuModel and that, apparently, can
>>> be session scoped, so it doen't help me.
>>>
>>> Glenn Silverman
>>>
>>> -----Original Message-----
>>> From: Zigc Junk [mailto:zigcjunk@gmail.com]
>>> Sent: Thursday, July 31, 2008 2:23 PM
>>> To: MyFaces Discussion
>>> Subject: Re: How can I create a session scoped Trinidad menu model
>>>
>>>
>>> Did u try to change from request to session? Since your bean is
>>> request scoped, every request will create a new instance of the bean,
>>> so does its property.
>>>
>>> regard
>>>
>>> Bill
>>>
>>> On Thu, Jul 31, 2008 at 4:05 PM, Silverman, Glenn <GS...@dylt.com> wrote:
>>>> I need a session-scoped menu model but the documentation says I can't, and
>>>> that creates a problem
>>>> whenever I click on a button to do something when I'm not on the first tab
>>>> of the menu. Here's my code...
>>>> I have a trinidad switcher control managed by a commandNavigationItem
>>>> control.
>>>>
>>>>                         <tr:navigationPane id="navPaneA" level="1"
>>>> value="#{root_menu}" var="foo">
>>>>                                 <f:facet name="nodeStamp">
>>>>                                         <tr:commandNavigationItem
>>>> id="navItemA" text="#{foo.label}"
>>>>                                                 action="#{foo.doAction}"/>
>>>>                                 </f:facet>
>>>>                         </tr:navigationPane>
>>>>
>>>>                         <tr:switcher facetName="#{root_menu.navLabel}"
>>>> defaultFacet="Messages" >
>>>>                                 <f:facet name="Messages">
>>>>                                 <tr:panelGroupLayout layout="vertical">
>>>>                                                 <jsp:include
>>>> page="../editors/errormessages.jspx"/>
>>>>                                         </tr:panelGroupLayout>
>>>>                                 </f:facet>
>>>>                                 <f:facet name="Help Text">
>>>>                                 <tr:panelGroupLayout layout="vertical">
>>>>                                                 <jsp:include
>>>> page="../editors/help.jspx"/>
>>>>                                         </tr:panelGroupLayout>
>>>>                                 </f:facet>
>>>>                         <f:facet name="Buttons">
>>>>                            <tr:panelGroupLayout layout="vertical">
>>>>                                                 <jsp:include
>>>> page="../editors/buttons.jspx"/>
>>>>                                         </tr:panelGroupLayout>
>>>>                                 </f:facet>
>>>>                                 <f:facet name="Sounds">
>>>>                                 <tr:panelGroupLayout layout="vertical">
>>>>                                                 <jsp:include
>>>> page="../editors/sounds.jspx"/>
>>>>                                         </tr:panelGroupLayout>
>>>>                                 </f:facet>
>>>>                         </tr:switcher>
>>>>
>>>> And a menu model:
>>>>
>>>>         <menu xmlns="http://myfaces.apache.org/trinidad/menu">
>>>>                 <groupNode id="msgs" idref="message" label="Error Messages"
>>>> defaultFocustPath="true">
>>>>                         <itemNode id="message" label="Messages"
>>>> action="goToMessages"
>>>>                                 focusViewId="/index.jspx"/>
>>>>                         <itemNode id="help" label="Help Text"
>>>> action="goToHelp"
>>>>                                 focusViewId="/index.jspx"/>
>>>>                         <itemNode id="button" label="Buttons"
>>>> action="goToButton"
>>>>                                 focusViewId="/index.jspx"/>
>>>>                         <itemNode id="sound" label="Sounds"
>>>> action="goToSound"
>>>>                                 focusViewId="/index.jspx"/>
>>>>                 </groupNode>
>>>>                 <groupNode id="allcodes" label="AllCodes" idref="cat">
>>>>
>>>>                         <itemNode id="cat" label="Categories"
>>>> action="goToCategory"
>>>>                                 focusViewId="/index.jspx" />
>>>>                         <itemNode id="link" label="CodeLinks"
>>>> action="goToLink"
>>>>                                 focusViewId="/index.jspx" />
>>>>                 </groupNode>
>>>>         </menu>
>>>>
>>>> which is defined in faces-config.xml as a managed bean:
>>>>
>>>>       <managed-bean>
>>>>         <managed-bean-name>root_menu</managed-bean-name>
>>>>         <managed-bean-class>com.dylt.bean.MenuModelBean</managed-bean-class>
>>>>         <managed-bean-scope>request</managed-bean-scope>
>>>>         <managed-property>
>>>>               <property-name>source</property-name>
>>>>               <property-class>java.lang.String</property-class>
>>>>               <value>/WEB-INF/menu-metadata.xml</value>
>>>>        </managed-property>
>>>>       </managed-bean>
>>>>
>>>> Here, MenuModelBean just extends XMLMenuModel as follows (This is
>>>> similar to the example in the Trinidad Developer Guide):
>>>>
>>>>         public class MenuModelBean extends XMLMenuModel {
>>>>
>>>>                 public String getGroupLabel(){
>>>>                         List list = getNodesFromFocusPath(false);
>>>>                         return (String)list.get(list.size()-1);
>>>>                 }
>>>>                 public String getNavLabel(){
>>>>                         List list = getNodesFromFocusPath(true);
>>>>                         return (String)list.get(list.size()-1);
>>>>                 }
>>>>         public List getNodesFromFocusPath(boolean itemsOnly){
>>>>         ArrayList focusPath = (ArrayList)this.getFocusRowKey();
>>>>         return getNodesFromFocusPath(focusPath, itemsOnly);
>>>>         }
>>>>
>>>>         public List getNodesFromFocusPath(ArrayList focusPath, boolean
>>>> itemsOnly){
>>>>
>>>>
>>>>               if (focusPath == null || focusPath.size() == 0)
>>>>                 return null;
>>>>
>>>>               // Clone the focusPath cause we remove elements
>>>>               ArrayList fp = (ArrayList) focusPath.clone();
>>>>
>>>>               // List of nodes to return
>>>>               List nodeList = new ArrayList<Object>();
>>>>
>>>>               // Convert String rowkey to int and point to the
>>>>               // node (row) corresponding to this index
>>>>               int targetNodeIdx = (Integer)fp.get(0);
>>>>               TreeModel tree = (TreeModel)this.getWrappedData();
>>>>
>>>>               tree.setRowIndex(targetNodeIdx);
>>>>
>>>>               // Get the node
>>>>               Object node = tree.getRowData();
>>>>               String label = null;
>>>>               if(node instanceof ItemNode){
>>>>                   label= ((ItemNode)node).getLabel();
>>>>                   if(itemsOnly)
>>>>                           nodeList.add(label);
>>>>               }
>>>>               else if (node instanceof GroupNode){
>>>>                   label= ((GroupNode)node).getLabel();
>>>>                   if(!itemsOnly)
>>>>                           nodeList.add(label);
>>>>               }
>>>>
>>>>
>>>>               // Remove the 0th rowkey from the focus path
>>>>               // leaving the remaining focus path
>>>>               fp.remove(0);
>>>>
>>>>               // traverse into children
>>>>               if (   fp.size() > 0
>>>>                   && tree.isContainer()
>>>>                   && !tree.isContainerEmpty()
>>>>                  )
>>>>               {
>>>>                 tree.enterContainer();
>>>>
>>>>                 // get list of nodes in remaining focusPath
>>>>                 List childList = getNodesFromFocusPath(fp, itemsOnly);
>>>>
>>>>                 // Add this list to the nodeList
>>>>                 nodeList.addAll(childList);
>>>>
>>>>                 tree.exitContainer();
>>>>               }
>>>>
>>>>               return nodeList;
>>>>             }
>>>>       )
>>>>
>>>> Here's the problem: If I'm on one of the facet pages other than the first
>>>> one, clicking
>>>> on any command button or link always takes me back to the first facet. If I
>>>> use
>>>> partialSubmit and partialTriggers to try to limit page refresh to a
>>>> particular page
>>>> element, the behavior is even more bizarre. If I click on a tab to change
>>>> facets, the
>>>> first command button or link click works as expected, but any subsequent
>>>> clicks assume
>>>> I am on the first facet page and won't update the facet page I'm on at all.
>>>>
>>>> Here's an example page, the help.jspx in the second facet:
>>>>
>>>>         jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
>>>>                 xmlns:f="http://java.sun.com/jsf/core"
>>>>                 xmlns:tr="http://myfaces.apache.org/trinidad">
>>>>         <jsp:directive.page contentType="text/html;charset=utf-8" />
>>>>                 <f:subview id="helpWrapperA">
>>>>                         <tr:table id="helpTableA" var="hlp"
>>>> value="#{helpBean.list}" partialTriggers="helpEditLink">
>>>>                                 <tr:column headerText="Id">
>>>>                                         <tr:outputText value="#{hlp.helpId}"
>>>> />
>>>>                                 </tr:column>
>>>>                                 <tr:column headerText="Message">
>>>>                                         <tr:commandLink id="helpEditLink"
>>>> text="#{hlp.text}"
>>>>                                                 immediate="true"
>>>> partialSubmit="true">
>>>>                                                 <tr:setActionListener
>>>> from="#{hlp}"
>>>>
>>>> to="#{pageFlowScope.helpDetail}" />
>>>>                                         </tr:commandLink>
>>>>                                 </tr:column>
>>>>                         </tr:table>
>>>>         </f:subview>
>>>>         <tr:separator/>
>>>>         <tr:showDetail undisclosedText="Show Detail" disclosedText="Hide
>>>> Detail">
>>>>                 <f:subview id="helpWrapperB">
>>>>                                 <tr:panelFormLayout rows="2"
>>>>
>>>> partialTriggers=":::helpWrapperA:helpTableA:helpEditLink">
>>>>                                         <tr:outputText value="ID:" />
>>>>                                         <tr:outputText value="Text:" />
>>>>                                         <tr:outputText
>>>> value="#{pageFlowScope.helpDetail.helpId}" />
>>>>                                         <tr:inputText
>>>> value="#{pageFlowScope.helpDetail.text}"/>
>>>>                                 </tr:panelFormLayout>
>>>>                     </f:subview>
>>>>                 </tr:showDetail>
>>>>         </jsp:root>
>>>>
>>>> Could this behavior be the result of the fact that the scope for the menu
>>>> model must be "request" ? If so, then every subsequent
>>>>
>>>> "request" will always go to, or assume I'm on,  the default tab.  How can I
>>>> change this?
>>>>
>>>> Glenn Silverman
>>>>
>>>>
>>>
>>>
>>
>>
>
>

RE: How can I create a session scoped Trinidad menu model

Posted by "Silverman, Glenn" <GS...@dylt.com>.
I appreciate your help, but
I guess I'm not making myself clear. Full page PPR is just what I don't want.
Everything works fine as long as the focusViewIds on each of the itemNodes is
different. In other words, the XMLMenuModel forces the use of multiple pages, when 
all I want is a single jsp page that I can use with the XMLMenuModel and render only
the content (using a switcher control, for example) that is appropriate for the tab
selected.

If all I want to do is render read-only content, XMLMenuModel works as expected, but
if you want to send requests to the server from the rendered page, it breaks down because
it always assumes the default tab on return, even when doing PPR.

I hope this better explains the problem, and why I am disappointed with Trinidad.

Glenn...



<tr:commandButton id="myButton" text="Ok" actionListener="#{myButton.doSomething}" partialSubmit="true"/>
<tr:outputText value="#{root_menu.focusRowKey}" partialTriggers="myButton" />

and see what happens. I don't know of any simple way to describe this. It does not work as intended. The
Trinidad writers could not have wanted it so, otherwise, it makes XMLMenuModel useless.


-----Original Message-----
From: Andrew Robinson [mailto:andrew.rw.robinson@gmail.com]
Sent: Monday, August 04, 2008 10:02 AM
To: MyFaces Discussion
Subject: Re: How can I create a session scoped Trinidad menu model


Why do you want it to be session scoped? What advantage would that
have for you? The architecture is really coded for only one use case,
so trying to use it outside of how the Oracle developer thought you
would use it is really ugly. It probably needs a re-write at some
point.

-Andrew

On Mon, Aug 4, 2008 at 10:40 AM, Silverman, Glenn <GS...@dylt.com> wrote:
> I'm still in a quandry. I tried using ChildPropertyMenuModel and that turns out
> to be a nightmare just configuring in faces-config.xml, and, I could not get
> it to work using the "level" attribute on NavigationPane control to retrieve the children nodes.
>
> So, I'm back to trying to get XMLMenuModel to work. Does anyone know why you can't create it in
> session scope and/or, is there a work-around?
>
> Here's simple web app anyone can easily set up that demonstrates the problem.
>
> menu-metadata.xml:
> <menu xmlns="http://myfaces.apache.org/trinidad/menu">
>  <itemNode id="gin1" label="Global 0"
>              focusViewId="/index.jspx">
>    <itemNode id="in1" label="Tab 1" destination="index.jspx"
>              focusViewId="/index.jspx">
>    </itemNode>
>    <itemNode id="in2" label="Tab 2" destination="index.jspx"
>                focusViewId="/index.jspx"/>
>  </itemNode>
>  <itemNode id="gin1" label="Global 1"
>            destination="index.jspx"
>            focusViewId="/index.jspx"/>
>  <itemNode id="gin2" label="Global 2"
>            destination="index.jspx" focusViewId="/index.jspx"/>
> </menu>
>
>
> Faces-config.xml:
> <faces-config
>    xmlns="http://java.sun.com/xml/ns/javaee"
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
>    version="1.2">
>  <application>
>    <!-- Use the Trinidad RenderKit -->
>    <default-render-kit-id>org.apache.myfaces.trinidad.core</default-render-kit-id>
>   </application>
>
>   <!-- managed bean menu model -->
>     <managed-bean>
>       <managed-bean-name>root_menu</managed-bean-name>
>       <managed-bean-class>org.apache.myfaces.trinidad.model.XMLMenuModel</managed-bean-class>
>       <managed-bean-scope>request</managed-bean-scope>
>       <managed-property>
>         <property-name>source</property-name>
>         <value>/WEB-INF/menu-metadata.xml</value>
>       </managed-property>
>     </managed-bean>
> </faces-config>
>
>
> Index.jspx
> <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
> <jsp:root version="1.2"
>  xmlns:jsp="http://java.sun.com/JSP/Page"
>  xmlns:f="http://java.sun.com/jsf/core"
>  xmlns:tr="http://myfaces.apache.org/trinidad">
>  <jsp:directive.page contentType="text/html;charset=utf-8"/>
>  <f:view>
>    <tr:document title="MenuModel Demo">
>      <tr:form>
>       <tr:page var="foo" value="#{root_menu}">
>          <f:facet name="branding">
>            <tr:panelGroupLayout layout="vertical">
>               <tr:outputText value="MenuModel"/>
>            </tr:panelGroupLayout>
>          </f:facet>
>          <tr:panelHorizontalLayout valign="top" >
>            <f:facet name="separator">
>                        <tr:spacer width="10" height="1"/>
>                        </f:facet>
>           <tr:navigationTree var="foo" value="#{root_menu}">
>                                <f:facet name="nodeStamp">
>                                        <tr:commandNavigationItem
>                                          text="#{foo.label}"
>                                          action="#{foo.doAction}"/>
>                              </f:facet>
>                </tr:navigationTree>
>                <tr:panelGroupLayout layout="vertical">
>                            <tr:navigationPane var="foo" value="#{root_menu}" level="1" >
>                                                <f:facet name="nodeStamp">
>                                                        <tr:commandNavigationItem
>                                                          text="#{foo.label}"
>                                                          action="#{foo.doAction}"/>
>                                              </f:facet>
>                            </tr:navigationPane>
>                    <tr:panelHorizontalLayout valign="top">
>                        <tr:commandButton id="myButton" text="Ok" actionListener="#{myButton.doSomething}"/>
>                        <tr:outputText value="#{root_menu.focusRowKey}" />
>                    </tr:panelHorizontalLayout>
>                </tr:panelGroupLayout>
>          </tr:panelHorizontalLayout>
>        </tr:page>
>      </tr:form>
>    </tr:document>
>  </f:view>
> </jsp:root>
>
>
> Index.jspx just has a left-side tree pane that uses the menu and a panel layout that uses the level 1 menu
> items as tabs. The page has a single button that when clicked, shows the focusRowKey of the selected menu
> item.
>
> Clicking the button twice always takes you back to focusRowKey=[0] the first menu item, which in
> this case is the itemNode, "Global 0", no matter what tab you selected. That's because the menu is
> in request scope. I've tried everything I can think of to capture the selected node in session and
> even pageFlowScope. but nothing seems to work.
>
> Has anyone been able to solve this issue. If not, then I will have to go back to Ajax4jsf, or some other
> JSF implementation to use in my apps.
>
> Glenn...
>
> -----Original Message-----
> From: Andrew Robinson [mailto:andrew.rw.robinson@gmail.com]
> Sent: Thursday, July 31, 2008 4:24 PM
> To: MyFaces Discussion
> Subject: Re: How can I create a session scoped Trinidad menu model
>
>
> My personal opinion would be to not use it. It really gave me
> heartburn when I attempted to use it. I would recommend using
> ChildPropertyMenuModel instead and if you want to use XML, use the
> commons digester with it. That is just my opinion though.
>
> BTW, I think it really is application scoped in practice, as it uses
> one shared model, so there really isn't any state to save (like in the
> session). The architecture of it is very odd and a bit broken (you can
> only have one menu model on a page for example).
>
> -Andrew
>
> On Thu, Jul 31, 2008 at 3:46 PM, Silverman, Glenn <GS...@dylt.com> wrote:
>> Are there any examples available of using XMLMenuModel. The
>> Trinidad demo apps use ProcessMenuModel and that, apparently, can
>> be session scoped, so it doen't help me.
>>
>> Glenn Silverman
>>
>> -----Original Message-----
>> From: Zigc Junk [mailto:zigcjunk@gmail.com]
>> Sent: Thursday, July 31, 2008 2:23 PM
>> To: MyFaces Discussion
>> Subject: Re: How can I create a session scoped Trinidad menu model
>>
>>
>> Did u try to change from request to session? Since your bean is
>> request scoped, every request will create a new instance of the bean,
>> so does its property.
>>
>> regard
>>
>> Bill
>>
>> On Thu, Jul 31, 2008 at 4:05 PM, Silverman, Glenn <GS...@dylt.com> wrote:
>>> I need a session-scoped menu model but the documentation says I can't, and
>>> that creates a problem
>>> whenever I click on a button to do something when I'm not on the first tab
>>> of the menu. Here's my code...
>>> I have a trinidad switcher control managed by a commandNavigationItem
>>> control.
>>>
>>>                         <tr:navigationPane id="navPaneA" level="1"
>>> value="#{root_menu}" var="foo">
>>>                                 <f:facet name="nodeStamp">
>>>                                         <tr:commandNavigationItem
>>> id="navItemA" text="#{foo.label}"
>>>                                                 action="#{foo.doAction}"/>
>>>                                 </f:facet>
>>>                         </tr:navigationPane>
>>>
>>>                         <tr:switcher facetName="#{root_menu.navLabel}"
>>> defaultFacet="Messages" >
>>>                                 <f:facet name="Messages">
>>>                                 <tr:panelGroupLayout layout="vertical">
>>>                                                 <jsp:include
>>> page="../editors/errormessages.jspx"/>
>>>                                         </tr:panelGroupLayout>
>>>                                 </f:facet>
>>>                                 <f:facet name="Help Text">
>>>                                 <tr:panelGroupLayout layout="vertical">
>>>                                                 <jsp:include
>>> page="../editors/help.jspx"/>
>>>                                         </tr:panelGroupLayout>
>>>                                 </f:facet>
>>>                         <f:facet name="Buttons">
>>>                            <tr:panelGroupLayout layout="vertical">
>>>                                                 <jsp:include
>>> page="../editors/buttons.jspx"/>
>>>                                         </tr:panelGroupLayout>
>>>                                 </f:facet>
>>>                                 <f:facet name="Sounds">
>>>                                 <tr:panelGroupLayout layout="vertical">
>>>                                                 <jsp:include
>>> page="../editors/sounds.jspx"/>
>>>                                         </tr:panelGroupLayout>
>>>                                 </f:facet>
>>>                         </tr:switcher>
>>>
>>> And a menu model:
>>>
>>>         <menu xmlns="http://myfaces.apache.org/trinidad/menu">
>>>                 <groupNode id="msgs" idref="message" label="Error Messages"
>>> defaultFocustPath="true">
>>>                         <itemNode id="message" label="Messages"
>>> action="goToMessages"
>>>                                 focusViewId="/index.jspx"/>
>>>                         <itemNode id="help" label="Help Text"
>>> action="goToHelp"
>>>                                 focusViewId="/index.jspx"/>
>>>                         <itemNode id="button" label="Buttons"
>>> action="goToButton"
>>>                                 focusViewId="/index.jspx"/>
>>>                         <itemNode id="sound" label="Sounds"
>>> action="goToSound"
>>>                                 focusViewId="/index.jspx"/>
>>>                 </groupNode>
>>>                 <groupNode id="allcodes" label="AllCodes" idref="cat">
>>>
>>>                         <itemNode id="cat" label="Categories"
>>> action="goToCategory"
>>>                                 focusViewId="/index.jspx" />
>>>                         <itemNode id="link" label="CodeLinks"
>>> action="goToLink"
>>>                                 focusViewId="/index.jspx" />
>>>                 </groupNode>
>>>         </menu>
>>>
>>> which is defined in faces-config.xml as a managed bean:
>>>
>>>       <managed-bean>
>>>         <managed-bean-name>root_menu</managed-bean-name>
>>>         <managed-bean-class>com.dylt.bean.MenuModelBean</managed-bean-class>
>>>         <managed-bean-scope>request</managed-bean-scope>
>>>         <managed-property>
>>>               <property-name>source</property-name>
>>>               <property-class>java.lang.String</property-class>
>>>               <value>/WEB-INF/menu-metadata.xml</value>
>>>        </managed-property>
>>>       </managed-bean>
>>>
>>> Here, MenuModelBean just extends XMLMenuModel as follows (This is
>>> similar to the example in the Trinidad Developer Guide):
>>>
>>>         public class MenuModelBean extends XMLMenuModel {
>>>
>>>                 public String getGroupLabel(){
>>>                         List list = getNodesFromFocusPath(false);
>>>                         return (String)list.get(list.size()-1);
>>>                 }
>>>                 public String getNavLabel(){
>>>                         List list = getNodesFromFocusPath(true);
>>>                         return (String)list.get(list.size()-1);
>>>                 }
>>>         public List getNodesFromFocusPath(boolean itemsOnly){
>>>         ArrayList focusPath = (ArrayList)this.getFocusRowKey();
>>>         return getNodesFromFocusPath(focusPath, itemsOnly);
>>>         }
>>>
>>>         public List getNodesFromFocusPath(ArrayList focusPath, boolean
>>> itemsOnly){
>>>
>>>
>>>               if (focusPath == null || focusPath.size() == 0)
>>>                 return null;
>>>
>>>               // Clone the focusPath cause we remove elements
>>>               ArrayList fp = (ArrayList) focusPath.clone();
>>>
>>>               // List of nodes to return
>>>               List nodeList = new ArrayList<Object>();
>>>
>>>               // Convert String rowkey to int and point to the
>>>               // node (row) corresponding to this index
>>>               int targetNodeIdx = (Integer)fp.get(0);
>>>               TreeModel tree = (TreeModel)this.getWrappedData();
>>>
>>>               tree.setRowIndex(targetNodeIdx);
>>>
>>>               // Get the node
>>>               Object node = tree.getRowData();
>>>               String label = null;
>>>               if(node instanceof ItemNode){
>>>                   label= ((ItemNode)node).getLabel();
>>>                   if(itemsOnly)
>>>                           nodeList.add(label);
>>>               }
>>>               else if (node instanceof GroupNode){
>>>                   label= ((GroupNode)node).getLabel();
>>>                   if(!itemsOnly)
>>>                           nodeList.add(label);
>>>               }
>>>
>>>
>>>               // Remove the 0th rowkey from the focus path
>>>               // leaving the remaining focus path
>>>               fp.remove(0);
>>>
>>>               // traverse into children
>>>               if (   fp.size() > 0
>>>                   && tree.isContainer()
>>>                   && !tree.isContainerEmpty()
>>>                  )
>>>               {
>>>                 tree.enterContainer();
>>>
>>>                 // get list of nodes in remaining focusPath
>>>                 List childList = getNodesFromFocusPath(fp, itemsOnly);
>>>
>>>                 // Add this list to the nodeList
>>>                 nodeList.addAll(childList);
>>>
>>>                 tree.exitContainer();
>>>               }
>>>
>>>               return nodeList;
>>>             }
>>>       )
>>>
>>> Here's the problem: If I'm on one of the facet pages other than the first
>>> one, clicking
>>> on any command button or link always takes me back to the first facet. If I
>>> use
>>> partialSubmit and partialTriggers to try to limit page refresh to a
>>> particular page
>>> element, the behavior is even more bizarre. If I click on a tab to change
>>> facets, the
>>> first command button or link click works as expected, but any subsequent
>>> clicks assume
>>> I am on the first facet page and won't update the facet page I'm on at all.
>>>
>>> Here's an example page, the help.jspx in the second facet:
>>>
>>>         jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
>>>                 xmlns:f="http://java.sun.com/jsf/core"
>>>                 xmlns:tr="http://myfaces.apache.org/trinidad">
>>>         <jsp:directive.page contentType="text/html;charset=utf-8" />
>>>                 <f:subview id="helpWrapperA">
>>>                         <tr:table id="helpTableA" var="hlp"
>>> value="#{helpBean.list}" partialTriggers="helpEditLink">
>>>                                 <tr:column headerText="Id">
>>>                                         <tr:outputText value="#{hlp.helpId}"
>>> />
>>>                                 </tr:column>
>>>                                 <tr:column headerText="Message">
>>>                                         <tr:commandLink id="helpEditLink"
>>> text="#{hlp.text}"
>>>                                                 immediate="true"
>>> partialSubmit="true">
>>>                                                 <tr:setActionListener
>>> from="#{hlp}"
>>>
>>> to="#{pageFlowScope.helpDetail}" />
>>>                                         </tr:commandLink>
>>>                                 </tr:column>
>>>                         </tr:table>
>>>         </f:subview>
>>>         <tr:separator/>
>>>         <tr:showDetail undisclosedText="Show Detail" disclosedText="Hide
>>> Detail">
>>>                 <f:subview id="helpWrapperB">
>>>                                 <tr:panelFormLayout rows="2"
>>>
>>> partialTriggers=":::helpWrapperA:helpTableA:helpEditLink">
>>>                                         <tr:outputText value="ID:" />
>>>                                         <tr:outputText value="Text:" />
>>>                                         <tr:outputText
>>> value="#{pageFlowScope.helpDetail.helpId}" />
>>>                                         <tr:inputText
>>> value="#{pageFlowScope.helpDetail.text}"/>
>>>                                 </tr:panelFormLayout>
>>>                     </f:subview>
>>>                 </tr:showDetail>
>>>         </jsp:root>
>>>
>>> Could this behavior be the result of the fact that the scope for the menu
>>> model must be "request" ? If so, then every subsequent
>>>
>>> "request" will always go to, or assume I'm on,  the default tab.  How can I
>>> change this?
>>>
>>> Glenn Silverman
>>>
>>>
>>
>>
>
>


RE: How can I create a session scoped Trinidad menu model

Posted by "Silverman, Glenn" <GS...@dylt.com>.
Fine. I don't need it to be in session scope, but then, what about
the use case I've been wrestling with. In other words, how can
you use the menu tabs to navigate using a single page and partial
page rendering. It only works as long as the rendered panels, using
a switcher or some other controls, don't have any form commands that
issue requests back to the server.

That's not the way I understand such a common use-case should
work.

Glenn...

-----Original Message-----
From: Andrew Robinson [mailto:andrew.rw.robinson@gmail.com]
Sent: Monday, August 04, 2008 10:02 AM
To: MyFaces Discussion
Subject: Re: How can I create a session scoped Trinidad menu model


Why do you want it to be session scoped? What advantage would that
have for you? The architecture is really coded for only one use case,
so trying to use it outside of how the Oracle developer thought you
would use it is really ugly. It probably needs a re-write at some
point.

-Andrew

On Mon, Aug 4, 2008 at 10:40 AM, Silverman, Glenn <GS...@dylt.com> wrote:
> I'm still in a quandry. I tried using ChildPropertyMenuModel and that turns out
> to be a nightmare just configuring in faces-config.xml, and, I could not get
> it to work using the "level" attribute on NavigationPane control to retrieve the children nodes.
>
> So, I'm back to trying to get XMLMenuModel to work. Does anyone know why you can't create it in
> session scope and/or, is there a work-around?
>
> Here's simple web app anyone can easily set up that demonstrates the problem.
>
> menu-metadata.xml:
> <menu xmlns="http://myfaces.apache.org/trinidad/menu">
>  <itemNode id="gin1" label="Global 0"
>              focusViewId="/index.jspx">
>    <itemNode id="in1" label="Tab 1" destination="index.jspx"
>              focusViewId="/index.jspx">
>    </itemNode>
>    <itemNode id="in2" label="Tab 2" destination="index.jspx"
>                focusViewId="/index.jspx"/>
>  </itemNode>
>  <itemNode id="gin1" label="Global 1"
>            destination="index.jspx"
>            focusViewId="/index.jspx"/>
>  <itemNode id="gin2" label="Global 2"
>            destination="index.jspx" focusViewId="/index.jspx"/>
> </menu>
>
>
> Faces-config.xml:
> <faces-config
>    xmlns="http://java.sun.com/xml/ns/javaee"
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
>    version="1.2">
>  <application>
>    <!-- Use the Trinidad RenderKit -->
>    <default-render-kit-id>org.apache.myfaces.trinidad.core</default-render-kit-id>
>   </application>
>
>   <!-- managed bean menu model -->
>     <managed-bean>
>       <managed-bean-name>root_menu</managed-bean-name>
>       <managed-bean-class>org.apache.myfaces.trinidad.model.XMLMenuModel</managed-bean-class>
>       <managed-bean-scope>request</managed-bean-scope>
>       <managed-property>
>         <property-name>source</property-name>
>         <value>/WEB-INF/menu-metadata.xml</value>
>       </managed-property>
>     </managed-bean>
> </faces-config>
>
>
> Index.jspx
> <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
> <jsp:root version="1.2"
>  xmlns:jsp="http://java.sun.com/JSP/Page"
>  xmlns:f="http://java.sun.com/jsf/core"
>  xmlns:tr="http://myfaces.apache.org/trinidad">
>  <jsp:directive.page contentType="text/html;charset=utf-8"/>
>  <f:view>
>    <tr:document title="MenuModel Demo">
>      <tr:form>
>       <tr:page var="foo" value="#{root_menu}">
>          <f:facet name="branding">
>            <tr:panelGroupLayout layout="vertical">
>               <tr:outputText value="MenuModel"/>
>            </tr:panelGroupLayout>
>          </f:facet>
>          <tr:panelHorizontalLayout valign="top" >
>            <f:facet name="separator">
>                        <tr:spacer width="10" height="1"/>
>                        </f:facet>
>           <tr:navigationTree var="foo" value="#{root_menu}">
>                                <f:facet name="nodeStamp">
>                                        <tr:commandNavigationItem
>                                          text="#{foo.label}"
>                                          action="#{foo.doAction}"/>
>                              </f:facet>
>                </tr:navigationTree>
>                <tr:panelGroupLayout layout="vertical">
>                            <tr:navigationPane var="foo" value="#{root_menu}" level="1" >
>                                                <f:facet name="nodeStamp">
>                                                        <tr:commandNavigationItem
>                                                          text="#{foo.label}"
>                                                          action="#{foo.doAction}"/>
>                                              </f:facet>
>                            </tr:navigationPane>
>                    <tr:panelHorizontalLayout valign="top">
>                        <tr:commandButton id="myButton" text="Ok" actionListener="#{myButton.doSomething}"/>
>                        <tr:outputText value="#{root_menu.focusRowKey}" />
>                    </tr:panelHorizontalLayout>
>                </tr:panelGroupLayout>
>          </tr:panelHorizontalLayout>
>        </tr:page>
>      </tr:form>
>    </tr:document>
>  </f:view>
> </jsp:root>
>
>
> Index.jspx just has a left-side tree pane that uses the menu and a panel layout that uses the level 1 menu
> items as tabs. The page has a single button that when clicked, shows the focusRowKey of the selected menu
> item.
>
> Clicking the button twice always takes you back to focusRowKey=[0] the first menu item, which in
> this case is the itemNode, "Global 0", no matter what tab you selected. That's because the menu is
> in request scope. I've tried everything I can think of to capture the selected node in session and
> even pageFlowScope. but nothing seems to work.
>
> Has anyone been able to solve this issue. If not, then I will have to go back to Ajax4jsf, or some other
> JSF implementation to use in my apps.
>
> Glenn...
>
> -----Original Message-----
> From: Andrew Robinson [mailto:andrew.rw.robinson@gmail.com]
> Sent: Thursday, July 31, 2008 4:24 PM
> To: MyFaces Discussion
> Subject: Re: How can I create a session scoped Trinidad menu model
>
>
> My personal opinion would be to not use it. It really gave me
> heartburn when I attempted to use it. I would recommend using
> ChildPropertyMenuModel instead and if you want to use XML, use the
> commons digester with it. That is just my opinion though.
>
> BTW, I think it really is application scoped in practice, as it uses
> one shared model, so there really isn't any state to save (like in the
> session). The architecture of it is very odd and a bit broken (you can
> only have one menu model on a page for example).
>
> -Andrew
>
> On Thu, Jul 31, 2008 at 3:46 PM, Silverman, Glenn <GS...@dylt.com> wrote:
>> Are there any examples available of using XMLMenuModel. The
>> Trinidad demo apps use ProcessMenuModel and that, apparently, can
>> be session scoped, so it doen't help me.
>>
>> Glenn Silverman
>>
>> -----Original Message-----
>> From: Zigc Junk [mailto:zigcjunk@gmail.com]
>> Sent: Thursday, July 31, 2008 2:23 PM
>> To: MyFaces Discussion
>> Subject: Re: How can I create a session scoped Trinidad menu model
>>
>>
>> Did u try to change from request to session? Since your bean is
>> request scoped, every request will create a new instance of the bean,
>> so does its property.
>>
>> regard
>>
>> Bill
>>
>> On Thu, Jul 31, 2008 at 4:05 PM, Silverman, Glenn <GS...@dylt.com> wrote:
>>> I need a session-scoped menu model but the documentation says I can't, and
>>> that creates a problem
>>> whenever I click on a button to do something when I'm not on the first tab
>>> of the menu. Here's my code...
>>> I have a trinidad switcher control managed by a commandNavigationItem
>>> control.
>>>
>>>                         <tr:navigationPane id="navPaneA" level="1"
>>> value="#{root_menu}" var="foo">
>>>                                 <f:facet name="nodeStamp">
>>>                                         <tr:commandNavigationItem
>>> id="navItemA" text="#{foo.label}"
>>>                                                 action="#{foo.doAction}"/>
>>>                                 </f:facet>
>>>                         </tr:navigationPane>
>>>
>>>                         <tr:switcher facetName="#{root_menu.navLabel}"
>>> defaultFacet="Messages" >
>>>                                 <f:facet name="Messages">
>>>                                 <tr:panelGroupLayout layout="vertical">
>>>                                                 <jsp:include
>>> page="../editors/errormessages.jspx"/>
>>>                                         </tr:panelGroupLayout>
>>>                                 </f:facet>
>>>                                 <f:facet name="Help Text">
>>>                                 <tr:panelGroupLayout layout="vertical">
>>>                                                 <jsp:include
>>> page="../editors/help.jspx"/>
>>>                                         </tr:panelGroupLayout>
>>>                                 </f:facet>
>>>                         <f:facet name="Buttons">
>>>                            <tr:panelGroupLayout layout="vertical">
>>>                                                 <jsp:include
>>> page="../editors/buttons.jspx"/>
>>>                                         </tr:panelGroupLayout>
>>>                                 </f:facet>
>>>                                 <f:facet name="Sounds">
>>>                                 <tr:panelGroupLayout layout="vertical">
>>>                                                 <jsp:include
>>> page="../editors/sounds.jspx"/>
>>>                                         </tr:panelGroupLayout>
>>>                                 </f:facet>
>>>                         </tr:switcher>
>>>
>>> And a menu model:
>>>
>>>         <menu xmlns="http://myfaces.apache.org/trinidad/menu">
>>>                 <groupNode id="msgs" idref="message" label="Error Messages"
>>> defaultFocustPath="true">
>>>                         <itemNode id="message" label="Messages"
>>> action="goToMessages"
>>>                                 focusViewId="/index.jspx"/>
>>>                         <itemNode id="help" label="Help Text"
>>> action="goToHelp"
>>>                                 focusViewId="/index.jspx"/>
>>>                         <itemNode id="button" label="Buttons"
>>> action="goToButton"
>>>                                 focusViewId="/index.jspx"/>
>>>                         <itemNode id="sound" label="Sounds"
>>> action="goToSound"
>>>                                 focusViewId="/index.jspx"/>
>>>                 </groupNode>
>>>                 <groupNode id="allcodes" label="AllCodes" idref="cat">
>>>
>>>                         <itemNode id="cat" label="Categories"
>>> action="goToCategory"
>>>                                 focusViewId="/index.jspx" />
>>>                         <itemNode id="link" label="CodeLinks"
>>> action="goToLink"
>>>                                 focusViewId="/index.jspx" />
>>>                 </groupNode>
>>>         </menu>
>>>
>>> which is defined in faces-config.xml as a managed bean:
>>>
>>>       <managed-bean>
>>>         <managed-bean-name>root_menu</managed-bean-name>
>>>         <managed-bean-class>com.dylt.bean.MenuModelBean</managed-bean-class>
>>>         <managed-bean-scope>request</managed-bean-scope>
>>>         <managed-property>
>>>               <property-name>source</property-name>
>>>               <property-class>java.lang.String</property-class>
>>>               <value>/WEB-INF/menu-metadata.xml</value>
>>>        </managed-property>
>>>       </managed-bean>
>>>
>>> Here, MenuModelBean just extends XMLMenuModel as follows (This is
>>> similar to the example in the Trinidad Developer Guide):
>>>
>>>         public class MenuModelBean extends XMLMenuModel {
>>>
>>>                 public String getGroupLabel(){
>>>                         List list = getNodesFromFocusPath(false);
>>>                         return (String)list.get(list.size()-1);
>>>                 }
>>>                 public String getNavLabel(){
>>>                         List list = getNodesFromFocusPath(true);
>>>                         return (String)list.get(list.size()-1);
>>>                 }
>>>         public List getNodesFromFocusPath(boolean itemsOnly){
>>>         ArrayList focusPath = (ArrayList)this.getFocusRowKey();
>>>         return getNodesFromFocusPath(focusPath, itemsOnly);
>>>         }
>>>
>>>         public List getNodesFromFocusPath(ArrayList focusPath, boolean
>>> itemsOnly){
>>>
>>>
>>>               if (focusPath == null || focusPath.size() == 0)
>>>                 return null;
>>>
>>>               // Clone the focusPath cause we remove elements
>>>               ArrayList fp = (ArrayList) focusPath.clone();
>>>
>>>               // List of nodes to return
>>>               List nodeList = new ArrayList<Object>();
>>>
>>>               // Convert String rowkey to int and point to the
>>>               // node (row) corresponding to this index
>>>               int targetNodeIdx = (Integer)fp.get(0);
>>>               TreeModel tree = (TreeModel)this.getWrappedData();
>>>
>>>               tree.setRowIndex(targetNodeIdx);
>>>
>>>               // Get the node
>>>               Object node = tree.getRowData();
>>>               String label = null;
>>>               if(node instanceof ItemNode){
>>>                   label= ((ItemNode)node).getLabel();
>>>                   if(itemsOnly)
>>>                           nodeList.add(label);
>>>               }
>>>               else if (node instanceof GroupNode){
>>>                   label= ((GroupNode)node).getLabel();
>>>                   if(!itemsOnly)
>>>                           nodeList.add(label);
>>>               }
>>>
>>>
>>>               // Remove the 0th rowkey from the focus path
>>>               // leaving the remaining focus path
>>>               fp.remove(0);
>>>
>>>               // traverse into children
>>>               if (   fp.size() > 0
>>>                   && tree.isContainer()
>>>                   && !tree.isContainerEmpty()
>>>                  )
>>>               {
>>>                 tree.enterContainer();
>>>
>>>                 // get list of nodes in remaining focusPath
>>>                 List childList = getNodesFromFocusPath(fp, itemsOnly);
>>>
>>>                 // Add this list to the nodeList
>>>                 nodeList.addAll(childList);
>>>
>>>                 tree.exitContainer();
>>>               }
>>>
>>>               return nodeList;
>>>             }
>>>       )
>>>
>>> Here's the problem: If I'm on one of the facet pages other than the first
>>> one, clicking
>>> on any command button or link always takes me back to the first facet. If I
>>> use
>>> partialSubmit and partialTriggers to try to limit page refresh to a
>>> particular page
>>> element, the behavior is even more bizarre. If I click on a tab to change
>>> facets, the
>>> first command button or link click works as expected, but any subsequent
>>> clicks assume
>>> I am on the first facet page and won't update the facet page I'm on at all.
>>>
>>> Here's an example page, the help.jspx in the second facet:
>>>
>>>         jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
>>>                 xmlns:f="http://java.sun.com/jsf/core"
>>>                 xmlns:tr="http://myfaces.apache.org/trinidad">
>>>         <jsp:directive.page contentType="text/html;charset=utf-8" />
>>>                 <f:subview id="helpWrapperA">
>>>                         <tr:table id="helpTableA" var="hlp"
>>> value="#{helpBean.list}" partialTriggers="helpEditLink">
>>>                                 <tr:column headerText="Id">
>>>                                         <tr:outputText value="#{hlp.helpId}"
>>> />
>>>                                 </tr:column>
>>>                                 <tr:column headerText="Message">
>>>                                         <tr:commandLink id="helpEditLink"
>>> text="#{hlp.text}"
>>>                                                 immediate="true"
>>> partialSubmit="true">
>>>                                                 <tr:setActionListener
>>> from="#{hlp}"
>>>
>>> to="#{pageFlowScope.helpDetail}" />
>>>                                         </tr:commandLink>
>>>                                 </tr:column>
>>>                         </tr:table>
>>>         </f:subview>
>>>         <tr:separator/>
>>>         <tr:showDetail undisclosedText="Show Detail" disclosedText="Hide
>>> Detail">
>>>                 <f:subview id="helpWrapperB">
>>>                                 <tr:panelFormLayout rows="2"
>>>
>>> partialTriggers=":::helpWrapperA:helpTableA:helpEditLink">
>>>                                         <tr:outputText value="ID:" />
>>>                                         <tr:outputText value="Text:" />
>>>                                         <tr:outputText
>>> value="#{pageFlowScope.helpDetail.helpId}" />
>>>                                         <tr:inputText
>>> value="#{pageFlowScope.helpDetail.text}"/>
>>>                                 </tr:panelFormLayout>
>>>                     </f:subview>
>>>                 </tr:showDetail>
>>>         </jsp:root>
>>>
>>> Could this behavior be the result of the fact that the scope for the menu
>>> model must be "request" ? If so, then every subsequent
>>>
>>> "request" will always go to, or assume I'm on,  the default tab.  How can I
>>> change this?
>>>
>>> Glenn Silverman
>>>
>>>
>>
>>
>
>


Re: How can I create a session scoped Trinidad menu model

Posted by Andrew Robinson <an...@gmail.com>.
Why do you want it to be session scoped? What advantage would that
have for you? The architecture is really coded for only one use case,
so trying to use it outside of how the Oracle developer thought you
would use it is really ugly. It probably needs a re-write at some
point.

-Andrew

On Mon, Aug 4, 2008 at 10:40 AM, Silverman, Glenn <GS...@dylt.com> wrote:
> I'm still in a quandry. I tried using ChildPropertyMenuModel and that turns out
> to be a nightmare just configuring in faces-config.xml, and, I could not get
> it to work using the "level" attribute on NavigationPane control to retrieve the children nodes.
>
> So, I'm back to trying to get XMLMenuModel to work. Does anyone know why you can't create it in
> session scope and/or, is there a work-around?
>
> Here's simple web app anyone can easily set up that demonstrates the problem.
>
> menu-metadata.xml:
> <menu xmlns="http://myfaces.apache.org/trinidad/menu">
>  <itemNode id="gin1" label="Global 0"
>              focusViewId="/index.jspx">
>    <itemNode id="in1" label="Tab 1" destination="index.jspx"
>              focusViewId="/index.jspx">
>    </itemNode>
>    <itemNode id="in2" label="Tab 2" destination="index.jspx"
>                focusViewId="/index.jspx"/>
>  </itemNode>
>  <itemNode id="gin1" label="Global 1"
>            destination="index.jspx"
>            focusViewId="/index.jspx"/>
>  <itemNode id="gin2" label="Global 2"
>            destination="index.jspx" focusViewId="/index.jspx"/>
> </menu>
>
>
> Faces-config.xml:
> <faces-config
>    xmlns="http://java.sun.com/xml/ns/javaee"
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
>    version="1.2">
>  <application>
>    <!-- Use the Trinidad RenderKit -->
>    <default-render-kit-id>org.apache.myfaces.trinidad.core</default-render-kit-id>
>   </application>
>
>   <!-- managed bean menu model -->
>     <managed-bean>
>       <managed-bean-name>root_menu</managed-bean-name>
>       <managed-bean-class>org.apache.myfaces.trinidad.model.XMLMenuModel</managed-bean-class>
>       <managed-bean-scope>request</managed-bean-scope>
>       <managed-property>
>         <property-name>source</property-name>
>         <value>/WEB-INF/menu-metadata.xml</value>
>       </managed-property>
>     </managed-bean>
> </faces-config>
>
>
> Index.jspx
> <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
> <jsp:root version="1.2"
>  xmlns:jsp="http://java.sun.com/JSP/Page"
>  xmlns:f="http://java.sun.com/jsf/core"
>  xmlns:tr="http://myfaces.apache.org/trinidad">
>  <jsp:directive.page contentType="text/html;charset=utf-8"/>
>  <f:view>
>    <tr:document title="MenuModel Demo">
>      <tr:form>
>       <tr:page var="foo" value="#{root_menu}">
>          <f:facet name="branding">
>            <tr:panelGroupLayout layout="vertical">
>               <tr:outputText value="MenuModel"/>
>            </tr:panelGroupLayout>
>          </f:facet>
>          <tr:panelHorizontalLayout valign="top" >
>            <f:facet name="separator">
>                        <tr:spacer width="10" height="1"/>
>                        </f:facet>
>           <tr:navigationTree var="foo" value="#{root_menu}">
>                                <f:facet name="nodeStamp">
>                                        <tr:commandNavigationItem
>                                          text="#{foo.label}"
>                                          action="#{foo.doAction}"/>
>                              </f:facet>
>                </tr:navigationTree>
>                <tr:panelGroupLayout layout="vertical">
>                            <tr:navigationPane var="foo" value="#{root_menu}" level="1" >
>                                                <f:facet name="nodeStamp">
>                                                        <tr:commandNavigationItem
>                                                          text="#{foo.label}"
>                                                          action="#{foo.doAction}"/>
>                                              </f:facet>
>                            </tr:navigationPane>
>                    <tr:panelHorizontalLayout valign="top">
>                        <tr:commandButton id="myButton" text="Ok" actionListener="#{myButton.doSomething}"/>
>                        <tr:outputText value="#{root_menu.focusRowKey}" />
>                    </tr:panelHorizontalLayout>
>                </tr:panelGroupLayout>
>          </tr:panelHorizontalLayout>
>        </tr:page>
>      </tr:form>
>    </tr:document>
>  </f:view>
> </jsp:root>
>
>
> Index.jspx just has a left-side tree pane that uses the menu and a panel layout that uses the level 1 menu
> items as tabs. The page has a single button that when clicked, shows the focusRowKey of the selected menu
> item.
>
> Clicking the button twice always takes you back to focusRowKey=[0] the first menu item, which in
> this case is the itemNode, "Global 0", no matter what tab you selected. That's because the menu is
> in request scope. I've tried everything I can think of to capture the selected node in session and
> even pageFlowScope. but nothing seems to work.
>
> Has anyone been able to solve this issue. If not, then I will have to go back to Ajax4jsf, or some other
> JSF implementation to use in my apps.
>
> Glenn...
>
> -----Original Message-----
> From: Andrew Robinson [mailto:andrew.rw.robinson@gmail.com]
> Sent: Thursday, July 31, 2008 4:24 PM
> To: MyFaces Discussion
> Subject: Re: How can I create a session scoped Trinidad menu model
>
>
> My personal opinion would be to not use it. It really gave me
> heartburn when I attempted to use it. I would recommend using
> ChildPropertyMenuModel instead and if you want to use XML, use the
> commons digester with it. That is just my opinion though.
>
> BTW, I think it really is application scoped in practice, as it uses
> one shared model, so there really isn't any state to save (like in the
> session). The architecture of it is very odd and a bit broken (you can
> only have one menu model on a page for example).
>
> -Andrew
>
> On Thu, Jul 31, 2008 at 3:46 PM, Silverman, Glenn <GS...@dylt.com> wrote:
>> Are there any examples available of using XMLMenuModel. The
>> Trinidad demo apps use ProcessMenuModel and that, apparently, can
>> be session scoped, so it doen't help me.
>>
>> Glenn Silverman
>>
>> -----Original Message-----
>> From: Zigc Junk [mailto:zigcjunk@gmail.com]
>> Sent: Thursday, July 31, 2008 2:23 PM
>> To: MyFaces Discussion
>> Subject: Re: How can I create a session scoped Trinidad menu model
>>
>>
>> Did u try to change from request to session? Since your bean is
>> request scoped, every request will create a new instance of the bean,
>> so does its property.
>>
>> regard
>>
>> Bill
>>
>> On Thu, Jul 31, 2008 at 4:05 PM, Silverman, Glenn <GS...@dylt.com> wrote:
>>> I need a session-scoped menu model but the documentation says I can't, and
>>> that creates a problem
>>> whenever I click on a button to do something when I'm not on the first tab
>>> of the menu. Here's my code...
>>> I have a trinidad switcher control managed by a commandNavigationItem
>>> control.
>>>
>>>                         <tr:navigationPane id="navPaneA" level="1"
>>> value="#{root_menu}" var="foo">
>>>                                 <f:facet name="nodeStamp">
>>>                                         <tr:commandNavigationItem
>>> id="navItemA" text="#{foo.label}"
>>>                                                 action="#{foo.doAction}"/>
>>>                                 </f:facet>
>>>                         </tr:navigationPane>
>>>
>>>                         <tr:switcher facetName="#{root_menu.navLabel}"
>>> defaultFacet="Messages" >
>>>                                 <f:facet name="Messages">
>>>                                 <tr:panelGroupLayout layout="vertical">
>>>                                                 <jsp:include
>>> page="../editors/errormessages.jspx"/>
>>>                                         </tr:panelGroupLayout>
>>>                                 </f:facet>
>>>                                 <f:facet name="Help Text">
>>>                                 <tr:panelGroupLayout layout="vertical">
>>>                                                 <jsp:include
>>> page="../editors/help.jspx"/>
>>>                                         </tr:panelGroupLayout>
>>>                                 </f:facet>
>>>                         <f:facet name="Buttons">
>>>                            <tr:panelGroupLayout layout="vertical">
>>>                                                 <jsp:include
>>> page="../editors/buttons.jspx"/>
>>>                                         </tr:panelGroupLayout>
>>>                                 </f:facet>
>>>                                 <f:facet name="Sounds">
>>>                                 <tr:panelGroupLayout layout="vertical">
>>>                                                 <jsp:include
>>> page="../editors/sounds.jspx"/>
>>>                                         </tr:panelGroupLayout>
>>>                                 </f:facet>
>>>                         </tr:switcher>
>>>
>>> And a menu model:
>>>
>>>         <menu xmlns="http://myfaces.apache.org/trinidad/menu">
>>>                 <groupNode id="msgs" idref="message" label="Error Messages"
>>> defaultFocustPath="true">
>>>                         <itemNode id="message" label="Messages"
>>> action="goToMessages"
>>>                                 focusViewId="/index.jspx"/>
>>>                         <itemNode id="help" label="Help Text"
>>> action="goToHelp"
>>>                                 focusViewId="/index.jspx"/>
>>>                         <itemNode id="button" label="Buttons"
>>> action="goToButton"
>>>                                 focusViewId="/index.jspx"/>
>>>                         <itemNode id="sound" label="Sounds"
>>> action="goToSound"
>>>                                 focusViewId="/index.jspx"/>
>>>                 </groupNode>
>>>                 <groupNode id="allcodes" label="AllCodes" idref="cat">
>>>
>>>                         <itemNode id="cat" label="Categories"
>>> action="goToCategory"
>>>                                 focusViewId="/index.jspx" />
>>>                         <itemNode id="link" label="CodeLinks"
>>> action="goToLink"
>>>                                 focusViewId="/index.jspx" />
>>>                 </groupNode>
>>>         </menu>
>>>
>>> which is defined in faces-config.xml as a managed bean:
>>>
>>>       <managed-bean>
>>>         <managed-bean-name>root_menu</managed-bean-name>
>>>         <managed-bean-class>com.dylt.bean.MenuModelBean</managed-bean-class>
>>>         <managed-bean-scope>request</managed-bean-scope>
>>>         <managed-property>
>>>               <property-name>source</property-name>
>>>               <property-class>java.lang.String</property-class>
>>>               <value>/WEB-INF/menu-metadata.xml</value>
>>>        </managed-property>
>>>       </managed-bean>
>>>
>>> Here, MenuModelBean just extends XMLMenuModel as follows (This is
>>> similar to the example in the Trinidad Developer Guide):
>>>
>>>         public class MenuModelBean extends XMLMenuModel {
>>>
>>>                 public String getGroupLabel(){
>>>                         List list = getNodesFromFocusPath(false);
>>>                         return (String)list.get(list.size()-1);
>>>                 }
>>>                 public String getNavLabel(){
>>>                         List list = getNodesFromFocusPath(true);
>>>                         return (String)list.get(list.size()-1);
>>>                 }
>>>         public List getNodesFromFocusPath(boolean itemsOnly){
>>>         ArrayList focusPath = (ArrayList)this.getFocusRowKey();
>>>         return getNodesFromFocusPath(focusPath, itemsOnly);
>>>         }
>>>
>>>         public List getNodesFromFocusPath(ArrayList focusPath, boolean
>>> itemsOnly){
>>>
>>>
>>>               if (focusPath == null || focusPath.size() == 0)
>>>                 return null;
>>>
>>>               // Clone the focusPath cause we remove elements
>>>               ArrayList fp = (ArrayList) focusPath.clone();
>>>
>>>               // List of nodes to return
>>>               List nodeList = new ArrayList<Object>();
>>>
>>>               // Convert String rowkey to int and point to the
>>>               // node (row) corresponding to this index
>>>               int targetNodeIdx = (Integer)fp.get(0);
>>>               TreeModel tree = (TreeModel)this.getWrappedData();
>>>
>>>               tree.setRowIndex(targetNodeIdx);
>>>
>>>               // Get the node
>>>               Object node = tree.getRowData();
>>>               String label = null;
>>>               if(node instanceof ItemNode){
>>>                   label= ((ItemNode)node).getLabel();
>>>                   if(itemsOnly)
>>>                           nodeList.add(label);
>>>               }
>>>               else if (node instanceof GroupNode){
>>>                   label= ((GroupNode)node).getLabel();
>>>                   if(!itemsOnly)
>>>                           nodeList.add(label);
>>>               }
>>>
>>>
>>>               // Remove the 0th rowkey from the focus path
>>>               // leaving the remaining focus path
>>>               fp.remove(0);
>>>
>>>               // traverse into children
>>>               if (   fp.size() > 0
>>>                   && tree.isContainer()
>>>                   && !tree.isContainerEmpty()
>>>                  )
>>>               {
>>>                 tree.enterContainer();
>>>
>>>                 // get list of nodes in remaining focusPath
>>>                 List childList = getNodesFromFocusPath(fp, itemsOnly);
>>>
>>>                 // Add this list to the nodeList
>>>                 nodeList.addAll(childList);
>>>
>>>                 tree.exitContainer();
>>>               }
>>>
>>>               return nodeList;
>>>             }
>>>       )
>>>
>>> Here's the problem: If I'm on one of the facet pages other than the first
>>> one, clicking
>>> on any command button or link always takes me back to the first facet. If I
>>> use
>>> partialSubmit and partialTriggers to try to limit page refresh to a
>>> particular page
>>> element, the behavior is even more bizarre. If I click on a tab to change
>>> facets, the
>>> first command button or link click works as expected, but any subsequent
>>> clicks assume
>>> I am on the first facet page and won't update the facet page I'm on at all.
>>>
>>> Here's an example page, the help.jspx in the second facet:
>>>
>>>         jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
>>>                 xmlns:f="http://java.sun.com/jsf/core"
>>>                 xmlns:tr="http://myfaces.apache.org/trinidad">
>>>         <jsp:directive.page contentType="text/html;charset=utf-8" />
>>>                 <f:subview id="helpWrapperA">
>>>                         <tr:table id="helpTableA" var="hlp"
>>> value="#{helpBean.list}" partialTriggers="helpEditLink">
>>>                                 <tr:column headerText="Id">
>>>                                         <tr:outputText value="#{hlp.helpId}"
>>> />
>>>                                 </tr:column>
>>>                                 <tr:column headerText="Message">
>>>                                         <tr:commandLink id="helpEditLink"
>>> text="#{hlp.text}"
>>>                                                 immediate="true"
>>> partialSubmit="true">
>>>                                                 <tr:setActionListener
>>> from="#{hlp}"
>>>
>>> to="#{pageFlowScope.helpDetail}" />
>>>                                         </tr:commandLink>
>>>                                 </tr:column>
>>>                         </tr:table>
>>>         </f:subview>
>>>         <tr:separator/>
>>>         <tr:showDetail undisclosedText="Show Detail" disclosedText="Hide
>>> Detail">
>>>                 <f:subview id="helpWrapperB">
>>>                                 <tr:panelFormLayout rows="2"
>>>
>>> partialTriggers=":::helpWrapperA:helpTableA:helpEditLink">
>>>                                         <tr:outputText value="ID:" />
>>>                                         <tr:outputText value="Text:" />
>>>                                         <tr:outputText
>>> value="#{pageFlowScope.helpDetail.helpId}" />
>>>                                         <tr:inputText
>>> value="#{pageFlowScope.helpDetail.text}"/>
>>>                                 </tr:panelFormLayout>
>>>                     </f:subview>
>>>                 </tr:showDetail>
>>>         </jsp:root>
>>>
>>> Could this behavior be the result of the fact that the scope for the menu
>>> model must be "request" ? If so, then every subsequent
>>>
>>> "request" will always go to, or assume I'm on,  the default tab.  How can I
>>> change this?
>>>
>>> Glenn Silverman
>>>
>>>
>>
>>
>
>

RE: How can I create a session scoped Trinidad menu model

Posted by "Silverman, Glenn" <GS...@dylt.com>.
I'm still in a quandry. I tried using ChildPropertyMenuModel and that turns out
to be a nightmare just configuring in faces-config.xml, and, I could not get
it to work using the "level" attribute on NavigationPane control to retrieve the children nodes.

So, I'm back to trying to get XMLMenuModel to work. Does anyone know why you can't create it in
session scope and/or, is there a work-around?

Here's simple web app anyone can easily set up that demonstrates the problem. 

menu-metadata.xml:
<menu xmlns="http://myfaces.apache.org/trinidad/menu">
  <itemNode id="gin1" label="Global 0"
              focusViewId="/index.jspx"> 
    <itemNode id="in1" label="Tab 1" destination="index.jspx"
              focusViewId="/index.jspx">      
    </itemNode>
    <itemNode id="in2" label="Tab 2" destination="index.jspx"
    		focusViewId="/index.jspx"/>
  </itemNode>
  <itemNode id="gin1" label="Global 1" 
            destination="index.jspx"
            focusViewId="/index.jspx"/>
  <itemNode id="gin2" label="Global 2" 
            destination="index.jspx" focusViewId="/index.jspx"/>
</menu>


Faces-config.xml:
<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
    version="1.2">
  <application>
    <!-- Use the Trinidad RenderKit -->
    <default-render-kit-id>org.apache.myfaces.trinidad.core</default-render-kit-id>    
   </application>
   
   <!-- managed bean menu model -->
     <managed-bean>
       <managed-bean-name>root_menu</managed-bean-name>
       <managed-bean-class>org.apache.myfaces.trinidad.model.XMLMenuModel</managed-bean-class>
       <managed-bean-scope>request</managed-bean-scope>
       <managed-property>
         <property-name>source</property-name>
         <value>/WEB-INF/menu-metadata.xml</value>
       </managed-property>
     </managed-bean>      
</faces-config>


Index.jspx
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<jsp:root version="1.2"
  xmlns:jsp="http://java.sun.com/JSP/Page"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:tr="http://myfaces.apache.org/trinidad">
  <jsp:directive.page contentType="text/html;charset=utf-8"/>
  <f:view>
    <tr:document title="MenuModel Demo">
      <tr:form>
       <tr:page var="foo" value="#{root_menu}">
          <f:facet name="branding">
            <tr:panelGroupLayout layout="vertical">
               <tr:outputText value="MenuModel"/>               
            </tr:panelGroupLayout>
          </f:facet>
          <tr:panelHorizontalLayout valign="top" >
            <f:facet name="separator">
    			<tr:spacer width="10" height="1"/>
  			</f:facet>
           <tr:navigationTree var="foo" value="#{root_menu}">
		           	<f:facet name="nodeStamp">                
			                <tr:commandNavigationItem
			                  text="#{foo.label}"
			                  action="#{foo.doAction}"/> 
		              </f:facet>
            	</tr:navigationTree>
                <tr:panelGroupLayout layout="vertical">
		            <tr:navigationPane var="foo" value="#{root_menu}" level="1" >
				           	<f:facet name="nodeStamp">                
					                <tr:commandNavigationItem
					                  text="#{foo.label}"
					                  action="#{foo.doAction}"/> 
				              </f:facet>
		            </tr:navigationPane>
                    <tr:panelHorizontalLayout valign="top">
                    	<tr:commandButton id="myButton" text="Ok" actionListener="#{myButton.doSomething}"/>
                    	<tr:outputText value="#{root_menu.focusRowKey}" />
                    </tr:panelHorizontalLayout> 
                </tr:panelGroupLayout> 
          </tr:panelHorizontalLayout>
        </tr:page>
      </tr:form>
    </tr:document>
  </f:view>
</jsp:root>


Index.jspx just has a left-side tree pane that uses the menu and a panel layout that uses the level 1 menu
items as tabs. The page has a single button that when clicked, shows the focusRowKey of the selected menu
item.

Clicking the button twice always takes you back to focusRowKey=[0] the first menu item, which in
this case is the itemNode, "Global 0", no matter what tab you selected. That's because the menu is
in request scope. I've tried everything I can think of to capture the selected node in session and
even pageFlowScope. but nothing seems to work.

Has anyone been able to solve this issue. If not, then I will have to go back to Ajax4jsf, or some other
JSF implementation to use in my apps.

Glenn...

-----Original Message-----
From: Andrew Robinson [mailto:andrew.rw.robinson@gmail.com]
Sent: Thursday, July 31, 2008 4:24 PM
To: MyFaces Discussion
Subject: Re: How can I create a session scoped Trinidad menu model


My personal opinion would be to not use it. It really gave me
heartburn when I attempted to use it. I would recommend using
ChildPropertyMenuModel instead and if you want to use XML, use the
commons digester with it. That is just my opinion though.

BTW, I think it really is application scoped in practice, as it uses
one shared model, so there really isn't any state to save (like in the
session). The architecture of it is very odd and a bit broken (you can
only have one menu model on a page for example).

-Andrew

On Thu, Jul 31, 2008 at 3:46 PM, Silverman, Glenn <GS...@dylt.com> wrote:
> Are there any examples available of using XMLMenuModel. The
> Trinidad demo apps use ProcessMenuModel and that, apparently, can
> be session scoped, so it doen't help me.
>
> Glenn Silverman
>
> -----Original Message-----
> From: Zigc Junk [mailto:zigcjunk@gmail.com]
> Sent: Thursday, July 31, 2008 2:23 PM
> To: MyFaces Discussion
> Subject: Re: How can I create a session scoped Trinidad menu model
>
>
> Did u try to change from request to session? Since your bean is
> request scoped, every request will create a new instance of the bean,
> so does its property.
>
> regard
>
> Bill
>
> On Thu, Jul 31, 2008 at 4:05 PM, Silverman, Glenn <GS...@dylt.com> wrote:
>> I need a session-scoped menu model but the documentation says I can't, and
>> that creates a problem
>> whenever I click on a button to do something when I'm not on the first tab
>> of the menu. Here's my code...
>> I have a trinidad switcher control managed by a commandNavigationItem
>> control.
>>
>>                         <tr:navigationPane id="navPaneA" level="1"
>> value="#{root_menu}" var="foo">
>>                                 <f:facet name="nodeStamp">
>>                                         <tr:commandNavigationItem
>> id="navItemA" text="#{foo.label}"
>>                                                 action="#{foo.doAction}"/>
>>                                 </f:facet>
>>                         </tr:navigationPane>
>>
>>                         <tr:switcher facetName="#{root_menu.navLabel}"
>> defaultFacet="Messages" >
>>                                 <f:facet name="Messages">
>>                                 <tr:panelGroupLayout layout="vertical">
>>                                                 <jsp:include
>> page="../editors/errormessages.jspx"/>
>>                                         </tr:panelGroupLayout>
>>                                 </f:facet>
>>                                 <f:facet name="Help Text">
>>                                 <tr:panelGroupLayout layout="vertical">
>>                                                 <jsp:include
>> page="../editors/help.jspx"/>
>>                                         </tr:panelGroupLayout>
>>                                 </f:facet>
>>                         <f:facet name="Buttons">
>>                            <tr:panelGroupLayout layout="vertical">
>>                                                 <jsp:include
>> page="../editors/buttons.jspx"/>
>>                                         </tr:panelGroupLayout>
>>                                 </f:facet>
>>                                 <f:facet name="Sounds">
>>                                 <tr:panelGroupLayout layout="vertical">
>>                                                 <jsp:include
>> page="../editors/sounds.jspx"/>
>>                                         </tr:panelGroupLayout>
>>                                 </f:facet>
>>                         </tr:switcher>
>>
>> And a menu model:
>>
>>         <menu xmlns="http://myfaces.apache.org/trinidad/menu">
>>                 <groupNode id="msgs" idref="message" label="Error Messages"
>> defaultFocustPath="true">
>>                         <itemNode id="message" label="Messages"
>> action="goToMessages"
>>                                 focusViewId="/index.jspx"/>
>>                         <itemNode id="help" label="Help Text"
>> action="goToHelp"
>>                                 focusViewId="/index.jspx"/>
>>                         <itemNode id="button" label="Buttons"
>> action="goToButton"
>>                                 focusViewId="/index.jspx"/>
>>                         <itemNode id="sound" label="Sounds"
>> action="goToSound"
>>                                 focusViewId="/index.jspx"/>
>>                 </groupNode>
>>                 <groupNode id="allcodes" label="AllCodes" idref="cat">
>>
>>                         <itemNode id="cat" label="Categories"
>> action="goToCategory"
>>                                 focusViewId="/index.jspx" />
>>                         <itemNode id="link" label="CodeLinks"
>> action="goToLink"
>>                                 focusViewId="/index.jspx" />
>>                 </groupNode>
>>         </menu>
>>
>> which is defined in faces-config.xml as a managed bean:
>>
>>       <managed-bean>
>>         <managed-bean-name>root_menu</managed-bean-name>
>>         <managed-bean-class>com.dylt.bean.MenuModelBean</managed-bean-class>
>>         <managed-bean-scope>request</managed-bean-scope>
>>         <managed-property>
>>               <property-name>source</property-name>
>>               <property-class>java.lang.String</property-class>
>>               <value>/WEB-INF/menu-metadata.xml</value>
>>        </managed-property>
>>       </managed-bean>
>>
>> Here, MenuModelBean just extends XMLMenuModel as follows (This is
>> similar to the example in the Trinidad Developer Guide):
>>
>>         public class MenuModelBean extends XMLMenuModel {
>>
>>                 public String getGroupLabel(){
>>                         List list = getNodesFromFocusPath(false);
>>                         return (String)list.get(list.size()-1);
>>                 }
>>                 public String getNavLabel(){
>>                         List list = getNodesFromFocusPath(true);
>>                         return (String)list.get(list.size()-1);
>>                 }
>>         public List getNodesFromFocusPath(boolean itemsOnly){
>>         ArrayList focusPath = (ArrayList)this.getFocusRowKey();
>>         return getNodesFromFocusPath(focusPath, itemsOnly);
>>         }
>>
>>         public List getNodesFromFocusPath(ArrayList focusPath, boolean
>> itemsOnly){
>>
>>
>>               if (focusPath == null || focusPath.size() == 0)
>>                 return null;
>>
>>               // Clone the focusPath cause we remove elements
>>               ArrayList fp = (ArrayList) focusPath.clone();
>>
>>               // List of nodes to return
>>               List nodeList = new ArrayList<Object>();
>>
>>               // Convert String rowkey to int and point to the
>>               // node (row) corresponding to this index
>>               int targetNodeIdx = (Integer)fp.get(0);
>>               TreeModel tree = (TreeModel)this.getWrappedData();
>>
>>               tree.setRowIndex(targetNodeIdx);
>>
>>               // Get the node
>>               Object node = tree.getRowData();
>>               String label = null;
>>               if(node instanceof ItemNode){
>>                   label= ((ItemNode)node).getLabel();
>>                   if(itemsOnly)
>>                           nodeList.add(label);
>>               }
>>               else if (node instanceof GroupNode){
>>                   label= ((GroupNode)node).getLabel();
>>                   if(!itemsOnly)
>>                           nodeList.add(label);
>>               }
>>
>>
>>               // Remove the 0th rowkey from the focus path
>>               // leaving the remaining focus path
>>               fp.remove(0);
>>
>>               // traverse into children
>>               if (   fp.size() > 0
>>                   && tree.isContainer()
>>                   && !tree.isContainerEmpty()
>>                  )
>>               {
>>                 tree.enterContainer();
>>
>>                 // get list of nodes in remaining focusPath
>>                 List childList = getNodesFromFocusPath(fp, itemsOnly);
>>
>>                 // Add this list to the nodeList
>>                 nodeList.addAll(childList);
>>
>>                 tree.exitContainer();
>>               }
>>
>>               return nodeList;
>>             }
>>       )
>>
>> Here's the problem: If I'm on one of the facet pages other than the first
>> one, clicking
>> on any command button or link always takes me back to the first facet. If I
>> use
>> partialSubmit and partialTriggers to try to limit page refresh to a
>> particular page
>> element, the behavior is even more bizarre. If I click on a tab to change
>> facets, the
>> first command button or link click works as expected, but any subsequent
>> clicks assume
>> I am on the first facet page and won't update the facet page I'm on at all.
>>
>> Here's an example page, the help.jspx in the second facet:
>>
>>         jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
>>                 xmlns:f="http://java.sun.com/jsf/core"
>>                 xmlns:tr="http://myfaces.apache.org/trinidad">
>>         <jsp:directive.page contentType="text/html;charset=utf-8" />
>>                 <f:subview id="helpWrapperA">
>>                         <tr:table id="helpTableA" var="hlp"
>> value="#{helpBean.list}" partialTriggers="helpEditLink">
>>                                 <tr:column headerText="Id">
>>                                         <tr:outputText value="#{hlp.helpId}"
>> />
>>                                 </tr:column>
>>                                 <tr:column headerText="Message">
>>                                         <tr:commandLink id="helpEditLink"
>> text="#{hlp.text}"
>>                                                 immediate="true"
>> partialSubmit="true">
>>                                                 <tr:setActionListener
>> from="#{hlp}"
>>
>> to="#{pageFlowScope.helpDetail}" />
>>                                         </tr:commandLink>
>>                                 </tr:column>
>>                         </tr:table>
>>         </f:subview>
>>         <tr:separator/>
>>         <tr:showDetail undisclosedText="Show Detail" disclosedText="Hide
>> Detail">
>>                 <f:subview id="helpWrapperB">
>>                                 <tr:panelFormLayout rows="2"
>>
>> partialTriggers=":::helpWrapperA:helpTableA:helpEditLink">
>>                                         <tr:outputText value="ID:" />
>>                                         <tr:outputText value="Text:" />
>>                                         <tr:outputText
>> value="#{pageFlowScope.helpDetail.helpId}" />
>>                                         <tr:inputText
>> value="#{pageFlowScope.helpDetail.text}"/>
>>                                 </tr:panelFormLayout>
>>                     </f:subview>
>>                 </tr:showDetail>
>>         </jsp:root>
>>
>> Could this behavior be the result of the fact that the scope for the menu
>> model must be "request" ? If so, then every subsequent
>>
>> "request" will always go to, or assume I'm on,  the default tab.  How can I
>> change this?
>>
>> Glenn Silverman
>>
>>
>
>


RE: How can I create a session scoped Trinidad menu model

Posted by "Silverman, Glenn" <GS...@dylt.com>.
Andrew,

Thanks for the heads up. I'll look into alternatives, as you suggested.

Glenn...

-----Original Message-----
From: Andrew Robinson [mailto:andrew.rw.robinson@gmail.com]
Sent: Thursday, July 31, 2008 4:24 PM
To: MyFaces Discussion
Subject: Re: How can I create a session scoped Trinidad menu model


My personal opinion would be to not use it. It really gave me
heartburn when I attempted to use it. I would recommend using
ChildPropertyMenuModel instead and if you want to use XML, use the
commons digester with it. That is just my opinion though.

BTW, I think it really is application scoped in practice, as it uses
one shared model, so there really isn't any state to save (like in the
session). The architecture of it is very odd and a bit broken (you can
only have one menu model on a page for example).

-Andrew

On Thu, Jul 31, 2008 at 3:46 PM, Silverman, Glenn <GS...@dylt.com> wrote:
> Are there any examples available of using XMLMenuModel. The
> Trinidad demo apps use ProcessMenuModel and that, apparently, can
> be session scoped, so it doen't help me.
>
> Glenn Silverman
>
> -----Original Message-----
> From: Zigc Junk [mailto:zigcjunk@gmail.com]
> Sent: Thursday, July 31, 2008 2:23 PM
> To: MyFaces Discussion
> Subject: Re: How can I create a session scoped Trinidad menu model
>
>
> Did u try to change from request to session? Since your bean is
> request scoped, every request will create a new instance of the bean,
> so does its property.
>
> regard
>
> Bill
>
> On Thu, Jul 31, 2008 at 4:05 PM, Silverman, Glenn <GS...@dylt.com> wrote:
>> I need a session-scoped menu model but the documentation says I can't, and
>> that creates a problem
>> whenever I click on a button to do something when I'm not on the first tab
>> of the menu. Here's my code...
>> I have a trinidad switcher control managed by a commandNavigationItem
>> control.
>>
>>                         <tr:navigationPane id="navPaneA" level="1"
>> value="#{root_menu}" var="foo">
>>                                 <f:facet name="nodeStamp">
>>                                         <tr:commandNavigationItem
>> id="navItemA" text="#{foo.label}"
>>                                                 action="#{foo.doAction}"/>
>>                                 </f:facet>
>>                         </tr:navigationPane>
>>
>>                         <tr:switcher facetName="#{root_menu.navLabel}"
>> defaultFacet="Messages" >
>>                                 <f:facet name="Messages">
>>                                 <tr:panelGroupLayout layout="vertical">
>>                                                 <jsp:include
>> page="../editors/errormessages.jspx"/>
>>                                         </tr:panelGroupLayout>
>>                                 </f:facet>
>>                                 <f:facet name="Help Text">
>>                                 <tr:panelGroupLayout layout="vertical">
>>                                                 <jsp:include
>> page="../editors/help.jspx"/>
>>                                         </tr:panelGroupLayout>
>>                                 </f:facet>
>>                         <f:facet name="Buttons">
>>                            <tr:panelGroupLayout layout="vertical">
>>                                                 <jsp:include
>> page="../editors/buttons.jspx"/>
>>                                         </tr:panelGroupLayout>
>>                                 </f:facet>
>>                                 <f:facet name="Sounds">
>>                                 <tr:panelGroupLayout layout="vertical">
>>                                                 <jsp:include
>> page="../editors/sounds.jspx"/>
>>                                         </tr:panelGroupLayout>
>>                                 </f:facet>
>>                         </tr:switcher>
>>
>> And a menu model:
>>
>>         <menu xmlns="http://myfaces.apache.org/trinidad/menu">
>>                 <groupNode id="msgs" idref="message" label="Error Messages"
>> defaultFocustPath="true">
>>                         <itemNode id="message" label="Messages"
>> action="goToMessages"
>>                                 focusViewId="/index.jspx"/>
>>                         <itemNode id="help" label="Help Text"
>> action="goToHelp"
>>                                 focusViewId="/index.jspx"/>
>>                         <itemNode id="button" label="Buttons"
>> action="goToButton"
>>                                 focusViewId="/index.jspx"/>
>>                         <itemNode id="sound" label="Sounds"
>> action="goToSound"
>>                                 focusViewId="/index.jspx"/>
>>                 </groupNode>
>>                 <groupNode id="allcodes" label="AllCodes" idref="cat">
>>
>>                         <itemNode id="cat" label="Categories"
>> action="goToCategory"
>>                                 focusViewId="/index.jspx" />
>>                         <itemNode id="link" label="CodeLinks"
>> action="goToLink"
>>                                 focusViewId="/index.jspx" />
>>                 </groupNode>
>>         </menu>
>>
>> which is defined in faces-config.xml as a managed bean:
>>
>>       <managed-bean>
>>         <managed-bean-name>root_menu</managed-bean-name>
>>         <managed-bean-class>com.dylt.bean.MenuModelBean</managed-bean-class>
>>         <managed-bean-scope>request</managed-bean-scope>
>>         <managed-property>
>>               <property-name>source</property-name>
>>               <property-class>java.lang.String</property-class>
>>               <value>/WEB-INF/menu-metadata.xml</value>
>>        </managed-property>
>>       </managed-bean>
>>
>> Here, MenuModelBean just extends XMLMenuModel as follows (This is
>> similar to the example in the Trinidad Developer Guide):
>>
>>         public class MenuModelBean extends XMLMenuModel {
>>
>>                 public String getGroupLabel(){
>>                         List list = getNodesFromFocusPath(false);
>>                         return (String)list.get(list.size()-1);
>>                 }
>>                 public String getNavLabel(){
>>                         List list = getNodesFromFocusPath(true);
>>                         return (String)list.get(list.size()-1);
>>                 }
>>         public List getNodesFromFocusPath(boolean itemsOnly){
>>         ArrayList focusPath = (ArrayList)this.getFocusRowKey();
>>         return getNodesFromFocusPath(focusPath, itemsOnly);
>>         }
>>
>>         public List getNodesFromFocusPath(ArrayList focusPath, boolean
>> itemsOnly){
>>
>>
>>               if (focusPath == null || focusPath.size() == 0)
>>                 return null;
>>
>>               // Clone the focusPath cause we remove elements
>>               ArrayList fp = (ArrayList) focusPath.clone();
>>
>>               // List of nodes to return
>>               List nodeList = new ArrayList<Object>();
>>
>>               // Convert String rowkey to int and point to the
>>               // node (row) corresponding to this index
>>               int targetNodeIdx = (Integer)fp.get(0);
>>               TreeModel tree = (TreeModel)this.getWrappedData();
>>
>>               tree.setRowIndex(targetNodeIdx);
>>
>>               // Get the node
>>               Object node = tree.getRowData();
>>               String label = null;
>>               if(node instanceof ItemNode){
>>                   label= ((ItemNode)node).getLabel();
>>                   if(itemsOnly)
>>                           nodeList.add(label);
>>               }
>>               else if (node instanceof GroupNode){
>>                   label= ((GroupNode)node).getLabel();
>>                   if(!itemsOnly)
>>                           nodeList.add(label);
>>               }
>>
>>
>>               // Remove the 0th rowkey from the focus path
>>               // leaving the remaining focus path
>>               fp.remove(0);
>>
>>               // traverse into children
>>               if (   fp.size() > 0
>>                   && tree.isContainer()
>>                   && !tree.isContainerEmpty()
>>                  )
>>               {
>>                 tree.enterContainer();
>>
>>                 // get list of nodes in remaining focusPath
>>                 List childList = getNodesFromFocusPath(fp, itemsOnly);
>>
>>                 // Add this list to the nodeList
>>                 nodeList.addAll(childList);
>>
>>                 tree.exitContainer();
>>               }
>>
>>               return nodeList;
>>             }
>>       )
>>
>> Here's the problem: If I'm on one of the facet pages other than the first
>> one, clicking
>> on any command button or link always takes me back to the first facet. If I
>> use
>> partialSubmit and partialTriggers to try to limit page refresh to a
>> particular page
>> element, the behavior is even more bizarre. If I click on a tab to change
>> facets, the
>> first command button or link click works as expected, but any subsequent
>> clicks assume
>> I am on the first facet page and won't update the facet page I'm on at all.
>>
>> Here's an example page, the help.jspx in the second facet:
>>
>>         jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
>>                 xmlns:f="http://java.sun.com/jsf/core"
>>                 xmlns:tr="http://myfaces.apache.org/trinidad">
>>         <jsp:directive.page contentType="text/html;charset=utf-8" />
>>                 <f:subview id="helpWrapperA">
>>                         <tr:table id="helpTableA" var="hlp"
>> value="#{helpBean.list}" partialTriggers="helpEditLink">
>>                                 <tr:column headerText="Id">
>>                                         <tr:outputText value="#{hlp.helpId}"
>> />
>>                                 </tr:column>
>>                                 <tr:column headerText="Message">
>>                                         <tr:commandLink id="helpEditLink"
>> text="#{hlp.text}"
>>                                                 immediate="true"
>> partialSubmit="true">
>>                                                 <tr:setActionListener
>> from="#{hlp}"
>>
>> to="#{pageFlowScope.helpDetail}" />
>>                                         </tr:commandLink>
>>                                 </tr:column>
>>                         </tr:table>
>>         </f:subview>
>>         <tr:separator/>
>>         <tr:showDetail undisclosedText="Show Detail" disclosedText="Hide
>> Detail">
>>                 <f:subview id="helpWrapperB">
>>                                 <tr:panelFormLayout rows="2"
>>
>> partialTriggers=":::helpWrapperA:helpTableA:helpEditLink">
>>                                         <tr:outputText value="ID:" />
>>                                         <tr:outputText value="Text:" />
>>                                         <tr:outputText
>> value="#{pageFlowScope.helpDetail.helpId}" />
>>                                         <tr:inputText
>> value="#{pageFlowScope.helpDetail.text}"/>
>>                                 </tr:panelFormLayout>
>>                     </f:subview>
>>                 </tr:showDetail>
>>         </jsp:root>
>>
>> Could this behavior be the result of the fact that the scope for the menu
>> model must be "request" ? If so, then every subsequent
>>
>> "request" will always go to, or assume I'm on,  the default tab.  How can I
>> change this?
>>
>> Glenn Silverman
>>
>>
>
>


Re: How can I create a session scoped Trinidad menu model

Posted by Andrew Robinson <an...@gmail.com>.
My personal opinion would be to not use it. It really gave me
heartburn when I attempted to use it. I would recommend using
ChildPropertyMenuModel instead and if you want to use XML, use the
commons digester with it. That is just my opinion though.

BTW, I think it really is application scoped in practice, as it uses
one shared model, so there really isn't any state to save (like in the
session). The architecture of it is very odd and a bit broken (you can
only have one menu model on a page for example).

-Andrew

On Thu, Jul 31, 2008 at 3:46 PM, Silverman, Glenn <GS...@dylt.com> wrote:
> Are there any examples available of using XMLMenuModel. The
> Trinidad demo apps use ProcessMenuModel and that, apparently, can
> be session scoped, so it doen't help me.
>
> Glenn Silverman
>
> -----Original Message-----
> From: Zigc Junk [mailto:zigcjunk@gmail.com]
> Sent: Thursday, July 31, 2008 2:23 PM
> To: MyFaces Discussion
> Subject: Re: How can I create a session scoped Trinidad menu model
>
>
> Did u try to change from request to session? Since your bean is
> request scoped, every request will create a new instance of the bean,
> so does its property.
>
> regard
>
> Bill
>
> On Thu, Jul 31, 2008 at 4:05 PM, Silverman, Glenn <GS...@dylt.com> wrote:
>> I need a session-scoped menu model but the documentation says I can't, and
>> that creates a problem
>> whenever I click on a button to do something when I'm not on the first tab
>> of the menu. Here's my code...
>> I have a trinidad switcher control managed by a commandNavigationItem
>> control.
>>
>>                         <tr:navigationPane id="navPaneA" level="1"
>> value="#{root_menu}" var="foo">
>>                                 <f:facet name="nodeStamp">
>>                                         <tr:commandNavigationItem
>> id="navItemA" text="#{foo.label}"
>>                                                 action="#{foo.doAction}"/>
>>                                 </f:facet>
>>                         </tr:navigationPane>
>>
>>                         <tr:switcher facetName="#{root_menu.navLabel}"
>> defaultFacet="Messages" >
>>                                 <f:facet name="Messages">
>>                                 <tr:panelGroupLayout layout="vertical">
>>                                                 <jsp:include
>> page="../editors/errormessages.jspx"/>
>>                                         </tr:panelGroupLayout>
>>                                 </f:facet>
>>                                 <f:facet name="Help Text">
>>                                 <tr:panelGroupLayout layout="vertical">
>>                                                 <jsp:include
>> page="../editors/help.jspx"/>
>>                                         </tr:panelGroupLayout>
>>                                 </f:facet>
>>                         <f:facet name="Buttons">
>>                            <tr:panelGroupLayout layout="vertical">
>>                                                 <jsp:include
>> page="../editors/buttons.jspx"/>
>>                                         </tr:panelGroupLayout>
>>                                 </f:facet>
>>                                 <f:facet name="Sounds">
>>                                 <tr:panelGroupLayout layout="vertical">
>>                                                 <jsp:include
>> page="../editors/sounds.jspx"/>
>>                                         </tr:panelGroupLayout>
>>                                 </f:facet>
>>                         </tr:switcher>
>>
>> And a menu model:
>>
>>         <menu xmlns="http://myfaces.apache.org/trinidad/menu">
>>                 <groupNode id="msgs" idref="message" label="Error Messages"
>> defaultFocustPath="true">
>>                         <itemNode id="message" label="Messages"
>> action="goToMessages"
>>                                 focusViewId="/index.jspx"/>
>>                         <itemNode id="help" label="Help Text"
>> action="goToHelp"
>>                                 focusViewId="/index.jspx"/>
>>                         <itemNode id="button" label="Buttons"
>> action="goToButton"
>>                                 focusViewId="/index.jspx"/>
>>                         <itemNode id="sound" label="Sounds"
>> action="goToSound"
>>                                 focusViewId="/index.jspx"/>
>>                 </groupNode>
>>                 <groupNode id="allcodes" label="AllCodes" idref="cat">
>>
>>                         <itemNode id="cat" label="Categories"
>> action="goToCategory"
>>                                 focusViewId="/index.jspx" />
>>                         <itemNode id="link" label="CodeLinks"
>> action="goToLink"
>>                                 focusViewId="/index.jspx" />
>>                 </groupNode>
>>         </menu>
>>
>> which is defined in faces-config.xml as a managed bean:
>>
>>       <managed-bean>
>>         <managed-bean-name>root_menu</managed-bean-name>
>>         <managed-bean-class>com.dylt.bean.MenuModelBean</managed-bean-class>
>>         <managed-bean-scope>request</managed-bean-scope>
>>         <managed-property>
>>               <property-name>source</property-name>
>>               <property-class>java.lang.String</property-class>
>>               <value>/WEB-INF/menu-metadata.xml</value>
>>        </managed-property>
>>       </managed-bean>
>>
>> Here, MenuModelBean just extends XMLMenuModel as follows (This is
>> similar to the example in the Trinidad Developer Guide):
>>
>>         public class MenuModelBean extends XMLMenuModel {
>>
>>                 public String getGroupLabel(){
>>                         List list = getNodesFromFocusPath(false);
>>                         return (String)list.get(list.size()-1);
>>                 }
>>                 public String getNavLabel(){
>>                         List list = getNodesFromFocusPath(true);
>>                         return (String)list.get(list.size()-1);
>>                 }
>>         public List getNodesFromFocusPath(boolean itemsOnly){
>>         ArrayList focusPath = (ArrayList)this.getFocusRowKey();
>>         return getNodesFromFocusPath(focusPath, itemsOnly);
>>         }
>>
>>         public List getNodesFromFocusPath(ArrayList focusPath, boolean
>> itemsOnly){
>>
>>
>>               if (focusPath == null || focusPath.size() == 0)
>>                 return null;
>>
>>               // Clone the focusPath cause we remove elements
>>               ArrayList fp = (ArrayList) focusPath.clone();
>>
>>               // List of nodes to return
>>               List nodeList = new ArrayList<Object>();
>>
>>               // Convert String rowkey to int and point to the
>>               // node (row) corresponding to this index
>>               int targetNodeIdx = (Integer)fp.get(0);
>>               TreeModel tree = (TreeModel)this.getWrappedData();
>>
>>               tree.setRowIndex(targetNodeIdx);
>>
>>               // Get the node
>>               Object node = tree.getRowData();
>>               String label = null;
>>               if(node instanceof ItemNode){
>>                   label= ((ItemNode)node).getLabel();
>>                   if(itemsOnly)
>>                           nodeList.add(label);
>>               }
>>               else if (node instanceof GroupNode){
>>                   label= ((GroupNode)node).getLabel();
>>                   if(!itemsOnly)
>>                           nodeList.add(label);
>>               }
>>
>>
>>               // Remove the 0th rowkey from the focus path
>>               // leaving the remaining focus path
>>               fp.remove(0);
>>
>>               // traverse into children
>>               if (   fp.size() > 0
>>                   && tree.isContainer()
>>                   && !tree.isContainerEmpty()
>>                  )
>>               {
>>                 tree.enterContainer();
>>
>>                 // get list of nodes in remaining focusPath
>>                 List childList = getNodesFromFocusPath(fp, itemsOnly);
>>
>>                 // Add this list to the nodeList
>>                 nodeList.addAll(childList);
>>
>>                 tree.exitContainer();
>>               }
>>
>>               return nodeList;
>>             }
>>       )
>>
>> Here's the problem: If I'm on one of the facet pages other than the first
>> one, clicking
>> on any command button or link always takes me back to the first facet. If I
>> use
>> partialSubmit and partialTriggers to try to limit page refresh to a
>> particular page
>> element, the behavior is even more bizarre. If I click on a tab to change
>> facets, the
>> first command button or link click works as expected, but any subsequent
>> clicks assume
>> I am on the first facet page and won't update the facet page I'm on at all.
>>
>> Here's an example page, the help.jspx in the second facet:
>>
>>         jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
>>                 xmlns:f="http://java.sun.com/jsf/core"
>>                 xmlns:tr="http://myfaces.apache.org/trinidad">
>>         <jsp:directive.page contentType="text/html;charset=utf-8" />
>>                 <f:subview id="helpWrapperA">
>>                         <tr:table id="helpTableA" var="hlp"
>> value="#{helpBean.list}" partialTriggers="helpEditLink">
>>                                 <tr:column headerText="Id">
>>                                         <tr:outputText value="#{hlp.helpId}"
>> />
>>                                 </tr:column>
>>                                 <tr:column headerText="Message">
>>                                         <tr:commandLink id="helpEditLink"
>> text="#{hlp.text}"
>>                                                 immediate="true"
>> partialSubmit="true">
>>                                                 <tr:setActionListener
>> from="#{hlp}"
>>
>> to="#{pageFlowScope.helpDetail}" />
>>                                         </tr:commandLink>
>>                                 </tr:column>
>>                         </tr:table>
>>         </f:subview>
>>         <tr:separator/>
>>         <tr:showDetail undisclosedText="Show Detail" disclosedText="Hide
>> Detail">
>>                 <f:subview id="helpWrapperB">
>>                                 <tr:panelFormLayout rows="2"
>>
>> partialTriggers=":::helpWrapperA:helpTableA:helpEditLink">
>>                                         <tr:outputText value="ID:" />
>>                                         <tr:outputText value="Text:" />
>>                                         <tr:outputText
>> value="#{pageFlowScope.helpDetail.helpId}" />
>>                                         <tr:inputText
>> value="#{pageFlowScope.helpDetail.text}"/>
>>                                 </tr:panelFormLayout>
>>                     </f:subview>
>>                 </tr:showDetail>
>>         </jsp:root>
>>
>> Could this behavior be the result of the fact that the scope for the menu
>> model must be "request" ? If so, then every subsequent
>>
>> "request" will always go to, or assume I'm on,  the default tab.  How can I
>> change this?
>>
>> Glenn Silverman
>>
>>
>
>

RE: How can I create a session scoped Trinidad menu model

Posted by "Silverman, Glenn" <GS...@dylt.com>.
Thanks for the reply.

Yes, I've tried that, and I get an exception:

Error calling action method of component with id j_id_jsp_374696285_3:navPaneA:1:navItemA

Caused by:
java.lang.NullPointerException - /includes/content_include.jspx(17,32) '#{foo.doAction}' java.lang.NullPointerException

It seems there is no foo (ItemNode). In fact the documentation in Developers Guide:XMLMenuModel says
"the scope for the menu model must be 'request'."

Glenn Silverman

-----Original Message-----
From: Zigc Junk [mailto:zigcjunk@gmail.com]
Sent: Thursday, July 31, 2008 2:23 PM
To: MyFaces Discussion
Subject: Re: How can I create a session scoped Trinidad menu model


Did u try to change from request to session? Since your bean is
request scoped, every request will create a new instance of the bean,
so does its property.

regard

Bill

On Thu, Jul 31, 2008 at 4:05 PM, Silverman, Glenn <GS...@dylt.com> wrote:
> I need a session-scoped menu model but the documentation says I can't, and
> that creates a problem
> whenever I click on a button to do something when I'm not on the first tab
> of the menu. Here's my code...
> I have a trinidad switcher control managed by a commandNavigationItem
> control.
>
>                         <tr:navigationPane id="navPaneA" level="1"
> value="#{root_menu}" var="foo">
>                                 <f:facet name="nodeStamp">
>                                         <tr:commandNavigationItem
> id="navItemA" text="#{foo.label}"
>                                                 action="#{foo.doAction}"/>
>                                 </f:facet>
>                         </tr:navigationPane>
>
>                         <tr:switcher facetName="#{root_menu.navLabel}"
> defaultFacet="Messages" >
>                                 <f:facet name="Messages">
>                                 <tr:panelGroupLayout layout="vertical">
>                                                 <jsp:include
> page="../editors/errormessages.jspx"/>
>                                         </tr:panelGroupLayout>
>                                 </f:facet>
>                                 <f:facet name="Help Text">
>                                 <tr:panelGroupLayout layout="vertical">
>                                                 <jsp:include
> page="../editors/help.jspx"/>
>                                         </tr:panelGroupLayout>
>                                 </f:facet>
>                         <f:facet name="Buttons">
>                            <tr:panelGroupLayout layout="vertical">
>                                                 <jsp:include
> page="../editors/buttons.jspx"/>
>                                         </tr:panelGroupLayout>
>                                 </f:facet>
>                                 <f:facet name="Sounds">
>                                 <tr:panelGroupLayout layout="vertical">
>                                                 <jsp:include
> page="../editors/sounds.jspx"/>
>                                         </tr:panelGroupLayout>
>                                 </f:facet>
>                         </tr:switcher>
>
> And a menu model:
>
>         <menu xmlns="http://myfaces.apache.org/trinidad/menu">
>                 <groupNode id="msgs" idref="message" label="Error Messages"
> defaultFocustPath="true">
>                         <itemNode id="message" label="Messages"
> action="goToMessages"
>                                 focusViewId="/index.jspx"/>
>                         <itemNode id="help" label="Help Text"
> action="goToHelp"
>                                 focusViewId="/index.jspx"/>
>                         <itemNode id="button" label="Buttons"
> action="goToButton"
>                                 focusViewId="/index.jspx"/>
>                         <itemNode id="sound" label="Sounds"
> action="goToSound"
>                                 focusViewId="/index.jspx"/>
>                 </groupNode>
>                 <groupNode id="allcodes" label="AllCodes" idref="cat">
>
>                         <itemNode id="cat" label="Categories"
> action="goToCategory"
>                                 focusViewId="/index.jspx" />
>                         <itemNode id="link" label="CodeLinks"
> action="goToLink"
>                                 focusViewId="/index.jspx" />
>                 </groupNode>
>         </menu>
>
> which is defined in faces-config.xml as a managed bean:
>
>       <managed-bean>
>         <managed-bean-name>root_menu</managed-bean-name>
>         <managed-bean-class>com.dylt.bean.MenuModelBean</managed-bean-class>
>         <managed-bean-scope>request</managed-bean-scope>
>         <managed-property>
>               <property-name>source</property-name>
>               <property-class>java.lang.String</property-class>
>               <value>/WEB-INF/menu-metadata.xml</value>
>        </managed-property>
>       </managed-bean>
>
> Here, MenuModelBean just extends XMLMenuModel as follows (This is
> similar to the example in the Trinidad Developer Guide):
>
>         public class MenuModelBean extends XMLMenuModel {
>
>                 public String getGroupLabel(){
>                         List list = getNodesFromFocusPath(false);
>                         return (String)list.get(list.size()-1);
>                 }
>                 public String getNavLabel(){
>                         List list = getNodesFromFocusPath(true);
>                         return (String)list.get(list.size()-1);
>                 }
>         public List getNodesFromFocusPath(boolean itemsOnly){
>         ArrayList focusPath = (ArrayList)this.getFocusRowKey();
>         return getNodesFromFocusPath(focusPath, itemsOnly);
>         }
>
>         public List getNodesFromFocusPath(ArrayList focusPath, boolean
> itemsOnly){
>
>
>               if (focusPath == null || focusPath.size() == 0)
>                 return null;
>
>               // Clone the focusPath cause we remove elements
>               ArrayList fp = (ArrayList) focusPath.clone();
>
>               // List of nodes to return
>               List nodeList = new ArrayList<Object>();
>
>               // Convert String rowkey to int and point to the
>               // node (row) corresponding to this index
>               int targetNodeIdx = (Integer)fp.get(0);
>               TreeModel tree = (TreeModel)this.getWrappedData();
>
>               tree.setRowIndex(targetNodeIdx);
>
>               // Get the node
>               Object node = tree.getRowData();
>               String label = null;
>               if(node instanceof ItemNode){
>                   label= ((ItemNode)node).getLabel();
>                   if(itemsOnly)
>                           nodeList.add(label);
>               }
>               else if (node instanceof GroupNode){
>                   label= ((GroupNode)node).getLabel();
>                   if(!itemsOnly)
>                           nodeList.add(label);
>               }
>
>
>               // Remove the 0th rowkey from the focus path
>               // leaving the remaining focus path
>               fp.remove(0);
>
>               // traverse into children
>               if (   fp.size() > 0
>                   && tree.isContainer()
>                   && !tree.isContainerEmpty()
>                  )
>               {
>                 tree.enterContainer();
>
>                 // get list of nodes in remaining focusPath
>                 List childList = getNodesFromFocusPath(fp, itemsOnly);
>
>                 // Add this list to the nodeList
>                 nodeList.addAll(childList);
>
>                 tree.exitContainer();
>               }
>
>               return nodeList;
>             }
>       )
>
> Here's the problem: If I'm on one of the facet pages other than the first
> one, clicking
> on any command button or link always takes me back to the first facet. If I
> use
> partialSubmit and partialTriggers to try to limit page refresh to a
> particular page
> element, the behavior is even more bizarre. If I click on a tab to change
> facets, the
> first command button or link click works as expected, but any subsequent
> clicks assume
> I am on the first facet page and won't update the facet page I'm on at all.
>
> Here's an example page, the help.jspx in the second facet:
>
>         jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
>                 xmlns:f="http://java.sun.com/jsf/core"
>                 xmlns:tr="http://myfaces.apache.org/trinidad">
>         <jsp:directive.page contentType="text/html;charset=utf-8" />
>                 <f:subview id="helpWrapperA">
>                         <tr:table id="helpTableA" var="hlp"
> value="#{helpBean.list}" partialTriggers="helpEditLink">
>                                 <tr:column headerText="Id">
>                                         <tr:outputText value="#{hlp.helpId}"
> />
>                                 </tr:column>
>                                 <tr:column headerText="Message">
>                                         <tr:commandLink id="helpEditLink"
> text="#{hlp.text}"
>                                                 immediate="true"
> partialSubmit="true">
>                                                 <tr:setActionListener
> from="#{hlp}"
>
> to="#{pageFlowScope.helpDetail}" />
>                                         </tr:commandLink>
>                                 </tr:column>
>                         </tr:table>
>         </f:subview>
>         <tr:separator/>
>         <tr:showDetail undisclosedText="Show Detail" disclosedText="Hide
> Detail">
>                 <f:subview id="helpWrapperB">
>                                 <tr:panelFormLayout rows="2"
>
> partialTriggers=":::helpWrapperA:helpTableA:helpEditLink">
>                                         <tr:outputText value="ID:" />
>                                         <tr:outputText value="Text:" />
>                                         <tr:outputText
> value="#{pageFlowScope.helpDetail.helpId}" />
>                                         <tr:inputText
> value="#{pageFlowScope.helpDetail.text}"/>
>                                 </tr:panelFormLayout>
>                     </f:subview>
>                 </tr:showDetail>
>         </jsp:root>
>
> Could this behavior be the result of the fact that the scope for the menu
> model must be "request" ? If so, then every subsequent
>
> "request" will always go to, or assume I'm on,  the default tab.  How can I
> change this?
>
> Glenn Silverman
>
>


RE: How can I create a session scoped Trinidad menu model

Posted by "Silverman, Glenn" <GS...@dylt.com>.
Are there any examples available of using XMLMenuModel. The
Trinidad demo apps use ProcessMenuModel and that, apparently, can
be session scoped, so it doen't help me.

Glenn Silverman

-----Original Message-----
From: Zigc Junk [mailto:zigcjunk@gmail.com]
Sent: Thursday, July 31, 2008 2:23 PM
To: MyFaces Discussion
Subject: Re: How can I create a session scoped Trinidad menu model


Did u try to change from request to session? Since your bean is
request scoped, every request will create a new instance of the bean,
so does its property.

regard

Bill

On Thu, Jul 31, 2008 at 4:05 PM, Silverman, Glenn <GS...@dylt.com> wrote:
> I need a session-scoped menu model but the documentation says I can't, and
> that creates a problem
> whenever I click on a button to do something when I'm not on the first tab
> of the menu. Here's my code...
> I have a trinidad switcher control managed by a commandNavigationItem
> control.
>
>                         <tr:navigationPane id="navPaneA" level="1"
> value="#{root_menu}" var="foo">
>                                 <f:facet name="nodeStamp">
>                                         <tr:commandNavigationItem
> id="navItemA" text="#{foo.label}"
>                                                 action="#{foo.doAction}"/>
>                                 </f:facet>
>                         </tr:navigationPane>
>
>                         <tr:switcher facetName="#{root_menu.navLabel}"
> defaultFacet="Messages" >
>                                 <f:facet name="Messages">
>                                 <tr:panelGroupLayout layout="vertical">
>                                                 <jsp:include
> page="../editors/errormessages.jspx"/>
>                                         </tr:panelGroupLayout>
>                                 </f:facet>
>                                 <f:facet name="Help Text">
>                                 <tr:panelGroupLayout layout="vertical">
>                                                 <jsp:include
> page="../editors/help.jspx"/>
>                                         </tr:panelGroupLayout>
>                                 </f:facet>
>                         <f:facet name="Buttons">
>                            <tr:panelGroupLayout layout="vertical">
>                                                 <jsp:include
> page="../editors/buttons.jspx"/>
>                                         </tr:panelGroupLayout>
>                                 </f:facet>
>                                 <f:facet name="Sounds">
>                                 <tr:panelGroupLayout layout="vertical">
>                                                 <jsp:include
> page="../editors/sounds.jspx"/>
>                                         </tr:panelGroupLayout>
>                                 </f:facet>
>                         </tr:switcher>
>
> And a menu model:
>
>         <menu xmlns="http://myfaces.apache.org/trinidad/menu">
>                 <groupNode id="msgs" idref="message" label="Error Messages"
> defaultFocustPath="true">
>                         <itemNode id="message" label="Messages"
> action="goToMessages"
>                                 focusViewId="/index.jspx"/>
>                         <itemNode id="help" label="Help Text"
> action="goToHelp"
>                                 focusViewId="/index.jspx"/>
>                         <itemNode id="button" label="Buttons"
> action="goToButton"
>                                 focusViewId="/index.jspx"/>
>                         <itemNode id="sound" label="Sounds"
> action="goToSound"
>                                 focusViewId="/index.jspx"/>
>                 </groupNode>
>                 <groupNode id="allcodes" label="AllCodes" idref="cat">
>
>                         <itemNode id="cat" label="Categories"
> action="goToCategory"
>                                 focusViewId="/index.jspx" />
>                         <itemNode id="link" label="CodeLinks"
> action="goToLink"
>                                 focusViewId="/index.jspx" />
>                 </groupNode>
>         </menu>
>
> which is defined in faces-config.xml as a managed bean:
>
>       <managed-bean>
>         <managed-bean-name>root_menu</managed-bean-name>
>         <managed-bean-class>com.dylt.bean.MenuModelBean</managed-bean-class>
>         <managed-bean-scope>request</managed-bean-scope>
>         <managed-property>
>               <property-name>source</property-name>
>               <property-class>java.lang.String</property-class>
>               <value>/WEB-INF/menu-metadata.xml</value>
>        </managed-property>
>       </managed-bean>
>
> Here, MenuModelBean just extends XMLMenuModel as follows (This is
> similar to the example in the Trinidad Developer Guide):
>
>         public class MenuModelBean extends XMLMenuModel {
>
>                 public String getGroupLabel(){
>                         List list = getNodesFromFocusPath(false);
>                         return (String)list.get(list.size()-1);
>                 }
>                 public String getNavLabel(){
>                         List list = getNodesFromFocusPath(true);
>                         return (String)list.get(list.size()-1);
>                 }
>         public List getNodesFromFocusPath(boolean itemsOnly){
>         ArrayList focusPath = (ArrayList)this.getFocusRowKey();
>         return getNodesFromFocusPath(focusPath, itemsOnly);
>         }
>
>         public List getNodesFromFocusPath(ArrayList focusPath, boolean
> itemsOnly){
>
>
>               if (focusPath == null || focusPath.size() == 0)
>                 return null;
>
>               // Clone the focusPath cause we remove elements
>               ArrayList fp = (ArrayList) focusPath.clone();
>
>               // List of nodes to return
>               List nodeList = new ArrayList<Object>();
>
>               // Convert String rowkey to int and point to the
>               // node (row) corresponding to this index
>               int targetNodeIdx = (Integer)fp.get(0);
>               TreeModel tree = (TreeModel)this.getWrappedData();
>
>               tree.setRowIndex(targetNodeIdx);
>
>               // Get the node
>               Object node = tree.getRowData();
>               String label = null;
>               if(node instanceof ItemNode){
>                   label= ((ItemNode)node).getLabel();
>                   if(itemsOnly)
>                           nodeList.add(label);
>               }
>               else if (node instanceof GroupNode){
>                   label= ((GroupNode)node).getLabel();
>                   if(!itemsOnly)
>                           nodeList.add(label);
>               }
>
>
>               // Remove the 0th rowkey from the focus path
>               // leaving the remaining focus path
>               fp.remove(0);
>
>               // traverse into children
>               if (   fp.size() > 0
>                   && tree.isContainer()
>                   && !tree.isContainerEmpty()
>                  )
>               {
>                 tree.enterContainer();
>
>                 // get list of nodes in remaining focusPath
>                 List childList = getNodesFromFocusPath(fp, itemsOnly);
>
>                 // Add this list to the nodeList
>                 nodeList.addAll(childList);
>
>                 tree.exitContainer();
>               }
>
>               return nodeList;
>             }
>       )
>
> Here's the problem: If I'm on one of the facet pages other than the first
> one, clicking
> on any command button or link always takes me back to the first facet. If I
> use
> partialSubmit and partialTriggers to try to limit page refresh to a
> particular page
> element, the behavior is even more bizarre. If I click on a tab to change
> facets, the
> first command button or link click works as expected, but any subsequent
> clicks assume
> I am on the first facet page and won't update the facet page I'm on at all.
>
> Here's an example page, the help.jspx in the second facet:
>
>         jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
>                 xmlns:f="http://java.sun.com/jsf/core"
>                 xmlns:tr="http://myfaces.apache.org/trinidad">
>         <jsp:directive.page contentType="text/html;charset=utf-8" />
>                 <f:subview id="helpWrapperA">
>                         <tr:table id="helpTableA" var="hlp"
> value="#{helpBean.list}" partialTriggers="helpEditLink">
>                                 <tr:column headerText="Id">
>                                         <tr:outputText value="#{hlp.helpId}"
> />
>                                 </tr:column>
>                                 <tr:column headerText="Message">
>                                         <tr:commandLink id="helpEditLink"
> text="#{hlp.text}"
>                                                 immediate="true"
> partialSubmit="true">
>                                                 <tr:setActionListener
> from="#{hlp}"
>
> to="#{pageFlowScope.helpDetail}" />
>                                         </tr:commandLink>
>                                 </tr:column>
>                         </tr:table>
>         </f:subview>
>         <tr:separator/>
>         <tr:showDetail undisclosedText="Show Detail" disclosedText="Hide
> Detail">
>                 <f:subview id="helpWrapperB">
>                                 <tr:panelFormLayout rows="2"
>
> partialTriggers=":::helpWrapperA:helpTableA:helpEditLink">
>                                         <tr:outputText value="ID:" />
>                                         <tr:outputText value="Text:" />
>                                         <tr:outputText
> value="#{pageFlowScope.helpDetail.helpId}" />
>                                         <tr:inputText
> value="#{pageFlowScope.helpDetail.text}"/>
>                                 </tr:panelFormLayout>
>                     </f:subview>
>                 </tr:showDetail>
>         </jsp:root>
>
> Could this behavior be the result of the fact that the scope for the menu
> model must be "request" ? If so, then every subsequent
>
> "request" will always go to, or assume I'm on,  the default tab.  How can I
> change this?
>
> Glenn Silverman
>
>