You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Yves Toubhans <yv...@oracle.com> on 2009/05/19 12:49:22 UTC

Trinidad XMLMenuModel

Hi Gurus,

I'm trying to use the new XMLMenuModel from Apache MyFaces Trinidad.
I got some code from here:  <http://myfaces.apache.org/trinidad/devguide/xmlMenuModel.html> http://myfaces.apache.org/trinidad/devguide/xmlMenuModel.html 
I've not been able to display my menu hierarchy ;-(

My understanding is that:

1 / I have to declare a menu hierarchy into an XML file. Here's the content of my test menu metadata.

<?xml version="1.0" encoding="windows-1252"?>
<menu xmlns="http://myfaces.apache.org/trinidad/menu" resourceBundle="menus" var="rmenus">
<itemNode id="root" label="Root" action="root" focusViewId=""/>
<itemNode id="g0" label="#{rmenus.airline}" action="global0" focusViewId="">
<itemNode id="g00" action="global00" focusViewId=""/>
<itemNode id="g01" action="global01" focusViewId=""/>
</itemNode>
<itemNode id="g1" label="Global 1" action="global1" focusViewId=""/>
<itemNode id="g2" label="Global 2" action="global2" focusViewId=""/>
</menu>

2 / Declare my metadata file into faces-config.xml

<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>

3 / reference it into my pages

Then use it in navigation panes into my JSPX pages. 

<trh:body>
<tr:form>
<tr:panelPage>
<f:facet name="navigation1">
<tr:navigationPane var="menutab" value="#{root_menu}" hint="tabs" level="1">
<f:facet name="nodeStamp">
<tr:commandNavigationItem text="#{menutab.label}" action="#{menutab.doAction}"/>
</f:facet>
</tr:navigationPane>
</f:facet>
<f:facet name="navigation2">
<tr:navigationPane var="menutab" value="#{root_menu}" hint="bar" level="2">
<f:facet name="nodeStamp">
<tr:commandNavigationItem text="#{menutab.label}" action="#{menutab.doAction}"/>
</f:facet>
</tr:navigationPane>
</f:facet>

 

…..

 

I cannot display a level 2 menu in my menubar. 

In fact, the only level accessible into my pages is the top one ;-(

 

What did I miss? 

 

 



Yves Toubhans | Consultant 
(+33) (0) 1 57 60 28 02
(+33) (0) 6 08 30 48 69
Oracle | Public Sector
15 Boulevard Charles de Gaulle 
92715 Colombes 
France

 


RE: Trinidad XMLMenuModel

Posted by Yves Toubhans <yv...@oracle.com>.
Thanks Abhi,

 

It works now ;-)

The last problem is to load a resource file to globalize my labels.

 

Yves

 



Yves Toubhans | Consultant 
(+33) (0) 1 57 60 28 02
(+33) (0) 6 08 30 48 69
Oracle | Public Sector
15 Boulevard Charles de Gaulle 
92715 Colombes 
France

 

  _____  

De : Abhijit Ghosh [mailto:abhijit.s.ghosh@gmail.com] 
Envoyé : Thursday, May 21, 2009 2:28 PM
À : MyFaces Discussion
Objet : Re: Trinidad XMLMenuModel

 

Yves,
Please try the following:

1) the level on tr:navigationPane is 0 based.I see just levels 0 and 1 in your xml menu metadata.So the levels on navigationPane should be 0 and 1

2) You would want to set the focusViewId on the itemNodes in your menu metadata xml,as without them you won't get selection state on the components which use the xmlMenuModel.

Thanks,
Abhi

On Tue, May 19, 2009 at 4:19 PM, Yves Toubhans <yv...@oracle.com> wrote:

Hi Gurus,

I'm trying to use the new XMLMenuModel from Apache MyFaces Trinidad.
I got some code from here:  <http://myfaces.apache.org/trinidad/devguide/xmlMenuModel.html> http://myfaces.apache.org/trinidad/devguide/xmlMenuModel.html 
I've not been able to display my menu hierarchy ;-(

My understanding is that:

1 / I have to declare a menu hierarchy into an XML file. Here's the content of my test menu metadata.

<?xml version="1.0" encoding="windows-1252"?>
<menu xmlns="http://myfaces.apache.org/trinidad/menu" resourceBundle="menus" var="rmenus">
<itemNode id="root" label="Root" action="root" focusViewId=""/>
<itemNode id="g0" label="#{rmenus.airline}" action="global0" focusViewId="">
<itemNode id="g00" action="global00" focusViewId=""/>
<itemNode id="g01" action="global01" focusViewId=""/>
</itemNode>
<itemNode id="g1" label="Global 1" action="global1" focusViewId=""/>
<itemNode id="g2" label="Global 2" action="global2" focusViewId=""/>
</menu>

2 / Declare my metadata file into faces-config.xml

<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>

3 / reference it into my pages

Then use it in navigation panes into my JSPX pages. 

<trh:body>
<tr:form>
<tr:panelPage>
<f:facet name="navigation1">
<tr:navigationPane var="menutab" value="#{root_menu}" hint="tabs" level="1">
<f:facet name="nodeStamp">
<tr:commandNavigationItem text="#{menutab.label}" action="#{menutab.doAction}"/>
</f:facet>
</tr:navigationPane>
</f:facet>
<f:facet name="navigation2">
<tr:navigationPane var="menutab" value="#{root_menu}" hint="bar" level="2">
<f:facet name="nodeStamp">
<tr:commandNavigationItem text="#{menutab.label}" action="#{menutab.doAction}"/>
</f:facet>
</tr:navigationPane>
</f:facet>

 

…..

 

I cannot display a level 2 menu in my menubar. 

In fact, the only level accessible into my pages is the top one ;-(

 

What did I miss? 

 

 



Yves Toubhans | Consultant 
(+33) (0) 1 57 60 28 02
(+33) (0) 6 08 30 48 69
Oracle | Public Sector
15 Boulevard Charles de Gaulle 
92715 Colombes 
France

 

 


Re: Trinidad XMLMenuModel

Posted by Abhijit Ghosh <ab...@gmail.com>.
Yves,
Please try the following:

1) the level on tr:navigationPane is 0 based.I see just levels 0 and 1 in
your xml menu metadata.So the levels on navigationPane should be 0 and 1

2) You would want to set the focusViewId on the itemNodes in your menu
metadata xml,as without them you won't get selection state on the components
which use the xmlMenuModel.

Thanks,
Abhi

On Tue, May 19, 2009 at 4:19 PM, Yves Toubhans <yv...@oracle.com>wrote:

>  Hi Gurus,
>
> I'm trying to use the new XMLMenuModel from Apache MyFaces Trinidad.
> I got some code from here:
> http://myfaces.apache.org/trinidad/devguide/xmlMenuModel.html
> I've not been able to display my menu hierarchy ;-(
>
> My understanding is that:
>
> 1 / I have to declare a menu hierarchy into an XML file. Here's the content
> of my test menu metadata.
>
> <?xml version="1.0" encoding="windows-1252"?>
> <menu xmlns="http://myfaces.apache.org/trinidad/menu"
> resourceBundle="menus" var="rmenus">
> <itemNode id="root" label="Root" action="root" focusViewId=""/>
> <itemNode id="g0" label="#{rmenus.airline}" action="global0"
> focusViewId="">
> <itemNode id="g00" action="global00" focusViewId=""/>
> <itemNode id="g01" action="global01" focusViewId=""/>
> </itemNode>
> <itemNode id="g1" label="Global 1" action="global1" focusViewId=""/>
> <itemNode id="g2" label="Global 2" action="global2" focusViewId=""/>
> </menu>
>
> 2 / Declare my metadata file into faces-config.xml
>
> <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>
>
> 3 / reference it into my pages
>
> Then use it in navigation panes into my JSPX pages.
>
> <trh:body>
> <tr:form>
> <tr:panelPage>
> <f:facet name="navigation1">
> *<tr:navigationPane var="menutab" value="#{root_menu}" hint="tabs"
> level="1">*
> <f:facet name="nodeStamp">
> <tr:commandNavigationItem text="#{menutab.label}"
> action="#{menutab.doAction}"/>
> </f:facet>
> </tr:navigationPane>
> </f:facet>
> <f:facet name="navigation2">
> *<tr:navigationPane var="menutab" value="#{root_menu}" hint="bar"
> level="2">
> *<f:facet name="nodeStamp">
> <tr:commandNavigationItem text="#{menutab.label}"
> action="#{menutab.doAction}"/>
> </f:facet>
> </tr:navigationPane>
> </f:facet>
>
>
>
> …..
>
>
>
> I cannot display a level 2 menu in my menubar.
>
> In fact, the only level accessible into my pages is the top one ;-(
>
>
>
> What did I miss?
>
>
>
>
>
>
>
> Yves Toubhans | Consultant
> (+33) (0) 1 57 60 28 02
> (+33) (0) 6 08 30 48 69
> Oracle | Public Sector
> 15 Boulevard Charles de Gaulle
> 92715 Colombes
> France
>
>
>