我正在尝试在checkobx值更改时在jsf dataTable中进行ajax调用。 但相应的支持bean不会被解雇。
当我在dataTable外面尝试相同的事情时,调用ajax调用并打印SOP。
以下是我的代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
>
<h:body>
<h:head></h:head>
<section class="box">
<h:form>
<f:event type="preRenderView" listener="#{adminAccounts.getAppInfoNew()}" />
<div class="row-fluid">
<div class="span7" style="">
<span class="heading">Manage Accounts</span>
</div>
</div>
<!-- outside dataTable ajax call is working -->
<h:selectBooleanCheckbox checked="checked"
value="#{adminAccounts.testValue}">
<f:ajax listener="#{adminAccounts.changingTabVisiblity}"></f:ajax>
</h:selectBooleanCheckbox>
<h:dataTable id="diagnosis_list_2"
value="#{adminAccounts.appsList}" var="apps">
<h:column>
<f:facet name="header">Position</f:facet>
#{apps.appname}
</h:column>
<h:column>
<f:facet name="header">Campaign Management</f:facet>
<!-- inside dataTable ajax call is not working -->
<h:selectBooleanCheckbox checked="checked"
value="#{adminAccounts.testValue}">
<f:ajax listener="#{adminAccounts.changingTabVisiblity}"></f:ajax>
</h:selectBooleanCheckbox>
</h:column>
</h:dataTable>
</h:form>
</section>
</h:body>
</html>
以下是bean类
@ManagedBean(name = "adminAccounts")
@RequestScoped
public class AdminAccounts {
private List<AppDummyList> appsList = new ArrayList<AppDummyList>();
public boolean testValue;
public boolean testValue1;
public boolean isTestValue1() {
return testValue1;
}
public void setTestValue1(boolean testValue1) {
this.testValue1 = testValue1;
}
public boolean isTestValue() {
return testValue;
}
public void setTestValue(boolean testValue) {
this.testValue = testValue;
}
public List<AppDummyList> getAppsList() {
return appsList;
}
public void setAppsList(List<AppDummyList> appsList) {
this.appsList = appsList;
}
public void getAppInfoNew() {
System.out.println("get info called");
appsList.add(new AppDummyList("amazon"));
appsList.add(new AppDummyList("bookmyshow"));
appsList.add(new AppDummyList("flipkart"));
appsList.add(new AppDummyList("foodpanda"));
}
public void changingTabVisiblity() {
System.out.println("value=" + testValue);
System.out.println("value1=" + testValue1);
}
}
需要帮助解释为什么ajax调用无法在dataTable中工作。