Dynamic <p:menu> implementation

UI Components for JSF
Post Reply
smallya
Posts: 264
Joined: 19 Mar 2010, 19:22
Contact:

28 Mar 2011, 22:41

Hi
I am trying to replace a <p:fieldset> implementation with a <p:menu> implementation so I can arrange the UI better. Here is what I am trying to do

My fieldset implementation

<p:fieldset legend="Filter" toggleable="true" collapsed="true">
<div id="foyo-category-filter">
<ul style="width:100%" >
<ui:repeat value="#{shoppingController.categories}" var="category">
<li style="width:20%">
<h:outputText styleClass="ui-icon ui-icon-gear foyo-icon-prefix" value=""/>
<p:commandLink value="#{category.categoryName}" update="productGridPanel,categoryFilterPanel" actionListener="#{shoppingController.clearProductFilter}">
<f:setPropertyActionListener value="#{category}" target="#{shoppingController.selectedCategory}" />
</p:commandLink>
</li>
</ui:repeat>
</ul>
</div>
</p:fieldset>

and on the managedbean side I am using a simple

public List<Category> getCategories() {
return ejbCategoryFacade.findAll();
}

With the menu based implementation

it will change to

<p:menu model="#{shoppingController.categoryMenu}"/>

the managed bean side will be

public MenuModel getCategoryMenuModel(){
if (categoryMenu == null) {
categoryMenu = new DefaultMenuModel();
for (Category category : ejbCategoryFacade.findAll()){
MenuItem item = new MenuItem();
item.setValue(category.getCategoryName());
item.setUrl("#");
categoryMenu.addMenuItem(item);
}
return categoryMenu;
}
return categoryMenu;
}

I am having some challenges implementing the ActionListeners (marked in red)
For the ActionListener (actionListener="#{shoppingController.clearProductFilter}) I can do

item.setActionListener(new ActionListener(...));

but for the <f:setPropertyActionListener> I am not sure the same would work. The MenuItem seems to support multiple ActionListeners. Has anyone tried this and point me to the right way to implement this.

Appreciate your help.
Netbeans 7.2| GlassFish 3.2 | PostgreSQL 9.1| MongoDB | Primefaces 3.4.2
_______________________________________________________________
Subraya Mallya
http://tinyhabit.com |http://twitter.com/tinyhabit

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 64 guests