我有一个primefaces表单,它有一组inputtext,datatable,最后是commandbutton。 First CommandButton" Full Submit"用于将所有表单输入提交给backbean,Second Commandbutton"部分提交"用于处理某些输入并将记录添加到数据表" itemDT" 点击"部分提交",在rowselect上的ajax请求表格数据表,将null SelectEvent传递给方法 点击"完整提交" ,在rowselect上的ajax请求表单数据表,传递非null SelectEvent到方法
<h:form id="generalForm">
<p:inputText label="full_submit_input_one" id="inpt1"/>
<p:inputText label="full_submit_input_two" id="inpt2"/>
<h:panelGrid columns="4" id="partial_submit_Panel">
<p:inputText label="partial_submit_input_one" id="inpt3"/>
<p:inputText label="partial_submit_input_two" id="inpt4"/>
</h:panelGrid>
<p:dataTable id="itemDT" var="item" value="#{itemView.items}" selectionMode="multiple"
selection="#{itemView.selectedItems}"
rowKey="#{fee.Id}">
<p:ajax event="rowSelect"
listener="#{dtFeesView.onRowSelect}" />
<p:column headerText="Input three">
<h:outputText value="#{fee.inpt3}" />
</p:column>
<p:column headerText="Input four">
<h:outputText value="#{fee.inpt4}" />
</p:column>
</p:dataTable>
<p:commandButton value="Full Submit" actionListener="#{itemView.add}"/>
<p:commandButton value="Partial Submit" actionListener="#{itemView.insertRecord}" process=":generalForm:partial_submit_Panel"/>
@ManagedBean(name="itemView")
@ViewScoped
public class ItemView{
private ItemModel selectedItems[];
// getters and setters for selectedItems
private List<ItemModel> items;
// getters and setters for items
public void add(){
// add item to i.e database
}
public void insertRecord(){
// add itemModels to items list
}
public void onRowSelect(SelectEvent event) {
ItemModel model =(ItemModel)event.getObject();
// model is null in case of process with value :generalForm:partial_submit_Panel
//model is not null in case of process with value generalForm "submit full form"
}
}
请帮忙。 感谢