Reputation: 10083
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?
Upvotes: 0
Views: 1674
Reputation: 28802
You need to escape quotes in strings. Specifically, this
"#{equityBean.onType("losers")}"
Is invalid as "#{equityBean.onType("
is parsed as the value, then the parser has an error as losers
is not a valid continuation
You need to write
"#{equityBean.onType("losers")}"
or
'#{equityBean.onType("losers")}'
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
Upvotes: 1