0
我正在使用PanelMenu和來自primefaces的數據表。 需要的是,當用戶點擊菜單項時,相應的數據應該填充到數據中。列表沒有得到填充在p:dataTable點擊p:menuitem
我的POC: 我能夠獲得託管bean中點擊的菜單項。
問題:
它來爲所需的方法,但該數據表不與結果的期望的一組填充。 下面是一段代碼。
@ManagedBean(name="msgTpye")
@SessionScoped
public class MsgType implements Serializable {
/**
*
*/
private static final long serialVersionUID = -3167238749130750720L;
/**
*
*/
private String msgdesription="";
private String msgtag="";
private String msgVal="";
private List<MsgType> msgValList;
public MsgType(){
}
public MsgType (String msgdesription,String msgtag,String msgVal){
this.msgdesription=msgdesription;
this.msgtag=msgtag;
this.msgVal=msgVal;
}
public List<MsgType> getMsgTypeList(ActionEvent event){
String msgType = (String) event.getComponent().getAttributes().get("msgTypeParam");
System.out.println("sss"+msgType);
List<MsgType> msgValList = new ArrayList<MsgType>();
if("FREETEXT".equals(msgType)){
msgValList.add(new MsgType(" ","{1100}", "30T N"));
msgValList.add(new MsgType(""," {1110}"," 10111353FT01"));
msgValList.add(new MsgType(""," {1120}" ,"20121011G1QX370C00004810111353FT01"));
msgValList.add(new MsgType(""," {1500}"," 30ABCDEFGHP"));
msgValList.add(new MsgType("","{1510} ","1000"));
msgValList.add(new MsgType("","{1520}"," 20121011J1Q504AC000001"));
msgValList.add(new MsgType(""," {2000}"," 000000000[AMOUNT]"));
msgValList.add(new MsgType("","{3100}", "101003317FST NATL BK KS*"));
msgValList.add(new MsgType("","{3320}"," [REFERENCE]*"));
msgValList.add(new MsgType("","{3400}" ,"101102315MARSHALL & ILSLEY*"));
msgValList.add(new MsgType("","{3600}"," CTR"));
msgValList.add(new MsgType("","{4100}", "D987543*RIVA BANK*10000 COLLEGE BLVD., STE. 260*OVERLAND OFAC PARK, KS 66210-1400*"));
msgValList.add(new MsgType("","{4200}"," D101004028651*KOESTEN, HIRSCHMANN & CRABTREE,*INC.*FLEXIBLE BENEFIT PLAN*"));
msgValList.add(new MsgType("","{5000}", "D077755*KOESTEN HIRSCHMANN & CRABTREE, INC.*10000 COLLEGE BLVD., STE. 260*OVERLAND OFAC PARK, KS 66210-1400*$"));
msgValList.add(new MsgType("Receiver FI Information ","{6100}" ,"D987543*[NAME]*10000 COLLEGE BLVD., STE. 260*OVERLAND OFAC PARK, KS 66210-1400*"));
}else {
msgValList.add(new MsgType("No Data ", "No data", "No Data"));
}
return msgValList;
}
}
我的XHTML頁面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h:outputStylesheet library="css" name="default.css" />
<h:outputStylesheet library="css" name="cssLayout.css" />
</h:head>
<h:body>
<br/>
<h:form style="width:100%;position:absolute;left:5%;top:22%;border:none">
<p:panelMenu style="width:100%;align:left">
<p:submenu label="#{msg.FREETEXT}" >
<p:menuitem value="#{msg.FREETEXT}" actionListener="#{msgTpye.getMsgTypeList}" icon="ui-icon-document" >
<f:attribute name="msgTypeParam" value="FREETEXT" />
</p:menuitem>
</p:submenu>
</p:panelMenu>
<p:dataTable id="dataTbl" var="value" value="#{msgTpye.msgValList}" style="width:100%; align:center;">
<p:column headerText="#{msg.Tag}">
<h:outputText value="#{value.msgtag}" />
</p:column>
<p:column headerText="#{msg.Description}">
<h:outputText value="#{value.msgdesription}" />
</p:column>
<p:column headerText="#{msg.Values}">
<h:outputText value="#{value.msgVal}" />
</p:column>
<p:column headerText="#{msg.Editable}"></p:column>
</p:dataTable>
</h:form>
請幫助。
:我確實改變了動作偵聽器方法,使其無效,並開始使用在級別級別 聲明的列表想要如何繼續使用AJAX。如果你引導我,這將會非常有幫助。我是JSF的新手。 – saharsh 2015-02-09 10:35:39
我不確定你評論中的問題。要在AJAX調用後更新數據表,只需將'update =「dataTbl」'添加到您的菜單項上 – stg 2015-02-09 10:40:32
可以讓我知道更多關於如何進行AJAX調用的信息。在我的菜單項中有多項目,所以我必須爲所有項添加更新。 – saharsh 2015-02-09 10:44:46