2012-05-25 30 views
0

我有3个表单,每个表单都包含包含数据表的组件。我希望将它们组合到一个表单中(因为每个表单都包含相同的一组UI组件)。我想到为此使用<p:menu><p:menu>带有3个menuItems,点击每个项目时,应呈现适当的表单内容。但是当我指定的<p:menu> action属性,我得到以下错误:primefaces 3.2 menuItem错误

Element type "p:menuitem" must be followed by either attribute specifications, ">" or "/>".

XHTML代码:

<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代码:

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

在那里我收到错了吗?

回答

1

您需要在字符串中转义引号。具体而言,该

"#{equityBean.onType("losers")}" 

是无效的,因为"#{equityBean.onType("被解析为值,则解析器有错误的losers不是一个有效的延续

你需要写

"#{equityBean.onType(&quot;losers&quot;)}" 

'#{equityBean.onType("losers")}' 

第一个逃脱的报价,第二个使用替代字符串分隔符(',而不是"),所以它不会与字符串

+0

内的报价冲突,谢谢它的工作!但现在我面临另一个问题,我在新问题中发帖 – z22