I have 3 forms each with component containing datatables. I wish to combine them into a single form (as each form contains the same set of UI components). I thought of using <p:menu> for this purpose. <p:menu> with 3 menuItems and on click of each item, appropriate form content should be rendered. but when I specify the action attribute of <p:menu>, I get the following error:
Element type “p:menuitem” must be followed by either attribute specifications, “>” or “/>”.
xhtml code:
<h:form id="frm">
<p:menu>
<p:menuitem value="price losers" action="#{equityBean.onType("losers")}"/>
<p:menuitem value="price gainers"/>
<p:menuitem value="price volume"/>
</p:menu>
<p:tabView activeIndex="#{equityBean.activeIndex}">
<p:ajax event="tabChange" listener="#{equityBean.onChange}" update=":frm"/>
<p:tab title="NSE">
<p:dataTable value="#{equityBean.scripList}" var="scrip">
....
</p:dataTable>
</p:tab>
<p:tab title="BSE">
<p:dataTable value="#{equityBean.scripList}" var="scrip">
.....
</p:dataTable>
</p:tab>
</p:tabView>
</h:form>
bean code:
public void onType(String type)
{
this.type=type;
}
public List<MasterScrip> getScripList() {
if(type.equalsIgnoreCase("losers"))
{
scripList=new ArrayList<MasterScrip> ();
scripList=getScripByPriceLosers(exchange);
return scripList;
}
else if(type.equalsIgnoreCase("gainers"))
{
scripList=new ArrayList<MasterScrip> ();
scripList=getScripByPriceLosers(exchange);
return scripList;
}
else
{
scripList=new ArrayList<MasterScrip> ();
scripList=getScripByVolumeType(exchange);
return scripList;
}
}
where am I getting wrong?
You need to escape quotes in strings. Specifically, this
Is invalid as
"#{equityBean.onType("is parsed as the value, then the parser has an error aslosersis not a valid continuationYou need to write
or
The first escapes the quote, the second uses an alternative string delimiter (
'instead of"), so it does not clash with the quote within the string