I have menu bar <p:submenu>
which have phone brands as its menu items these menu items should redirect to same page but loading data should different. So I tried to use param and viewparam to catch the brand name
Menu bar JSF code
<p:submenu label="PHONES">
<p:menuitem value="Apple" outcome="phones" >
<f:param name="brand" value="Apple" />
</p:menuitem>
<p:menuitem value="Motorola" outcome="phones" >
<f:param name="brand" value="Motorola"/>
</p:menuitem>
<p:menuitem value="Nokia" outcome="phones">
<f:param name="brand" value="Nokia"/>
</p:menuitem>
<p:menuitem value="Samsung" outcome="phones">
<f:param name="brand" value="Samsung"/>
</p:menuitem>
</p:submenu>
paramview code - this code is in different xhtml file. coded beginning of body
<h:body>
<f:metadata>
<f:viewParam name="brand" value="#{phonesBean.brand}" />
</f:metadata>
PhonesBean
@ManagedBean
@RequestScoped
public class PhonesBean implements Serializable {
private String brand;
private List<PhoneSummary>phoneList = new ArrayList<PhoneSummary>();
/**
* Creates a new instance of PhonesBean
*/
public PhonesBean() {
getPhoneModelList();
}
private void getPhoneModelList(){
brand=MenuItemManage.phoneBrand;
DbPhones dbPhones = new DbPhones();
phoneList=dbPhones.getPhonesSummary(brand);
}
}
Now when <p:menuitem>
is clicked it redirects to page with parameter tagging like "brand=Nokia" but I can't catch it from <f:viewParam>
and set it to a bean variable. How to fix this?