2012-05-25 58 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