我有这样的事情:
<h:form id="form">
<p:dialog id="profileDialogId">
<p:panelGrid id="categoryFunctions" columns="2" >
<p:outputPanel id="profileFunctions" >
<p:panelGrid columns="1" >
<p:scrollPanel scrollMode="buttons" mode="native" >
<p:outputLabel for="functionList" value="Functions:" />
<p:selectManyCheckbox id="functionList" value="#{profileConf.selectedCategoryDto.selectedFunctions}" layout="pageDirection" >
<f:selectItems value="#{profileConf.selectedCategoryDto.functionList}" var="function" itemLabel="#{function.functionDesc}" itemValue="#{function.functionCod}" />
</p:selectManyCheckbox>
</p:scrollPanel>
</p:panelGrid>
</p:outputPanel>
</p:panelGrid>
</p:dialog>
</h:form>
我想用ajax只发送带有&#34; functionsList&#34;的组件。标识。
我已经尝试了
<f:ajax event="valueChange" execute=":form:functionList" listener="#{profileConf.functionsForCategory}" update=":form:functionList"/>
但是当我在functionsForCategory方法中放置断点时,selectedFunctions属性为null。 任何帮助将不胜感激。谢谢!
答案 0 :(得分:2)
试试这个
<p:ajax event="valueChange" listener="#{profileConf.functionsForCategory}" process="@this" update=":form:functionList"/>
答案 1 :(得分:1)
p:selectManyCheckbox
的ajax行为将默认为默认事件valueChange。为了部分提交您的p:selectManyCheckbox
,您可以将其用作我的示例代码。
XHTML
<h:form id="form">
<p:commandButton value="popup" onclick="PF('profiledlg').show()"/>
<p:dialog id="profileDialogId" widgetVar="profiledlg">
<p:panelGrid id="categoryFunctions" columns="2" >
<p:outputPanel id="profileFunctions" >
<p:panelGrid columns="1" >
<p:scrollPanel mode="native" >
<p:outputLabel for="functionList"
value="Functions:" />
<p:selectManyCheckbox id="functionList"
value="#{profileConf.selectedFunctions}"
layout="pageDirection" >
<p:ajax listener="#{profileConf.functionsForCategory}"
process="functionList"
update="functionList"/>
<f:selectItems
value="#{profileConf.categorys}"
var="function"
itemLabel="#{function.functionDesc}"
itemValue="#{function.functionCod}" />
</p:selectManyCheckbox>
</p:scrollPanel>
</p:panelGrid>
</p:outputPanel>
</p:panelGrid>
<p:commandButton value="submit"
actionListener="#{profileConf.submit}"
process="@this,functionList"
update="@this,functionList"/>
</p:dialog>
</h:form>
managedbean
/**
*
* @author Wittakarn
*/
@ViewScoped
@ManagedBean(name = "profileConf")
public class ProfileConf {
private List<FunctionsForCategory> categorys;
private List<FunctionsForCategory> selectedFunctions;
public ProfileConf(){
categorys = new ArrayList<FunctionsForCategory>();
categorys.add(new FunctionsForCategory("A", "type A"));
categorys.add(new FunctionsForCategory("B", "type B"));
categorys.add(new FunctionsForCategory("C", "type C"));
categorys.add(new FunctionsForCategory("D", "type D"));
}
public List<FunctionsForCategory> getCategorys() {
return categorys;
}
public void setCategorys(List<FunctionsForCategory> categorys) {
this.categorys = categorys;
}
public List<FunctionsForCategory> getSelectedFunctions() {
return selectedFunctions;
}
public void setSelectedFunctions(List<FunctionsForCategory> selectedFunctions) {
this.selectedFunctions = selectedFunctions;
}
public void functionsForCategory(){
System.out.println("size of selectedFunctions = " + selectedFunctions.size());
}
public void submit(){
System.out.println("size of selectedFunctions = " + selectedFunctions.size());
}
}
域
/**
*
* @author Wittakarn
*/
public class FunctionsForCategory {
private String functionCod;
private String functionDesc;
public FunctionsForCategory(String functionCod, String functionDesc){
this.functionCod = functionCod;
this.functionDesc = functionDesc;
}
public String getFunctionCod() {
return functionCod;
}
public void setFunctionCod(String functionCod) {
this.functionCod = functionCod;
}
public String getFunctionDesc() {
return functionDesc;
}
public void setFunctionDesc(String functionDesc) {
this.functionDesc = functionDesc;
}
}