I need your help in updating a specific inputText component to be enabled in a dataTable once the checkbox in the row is ticked. Here is the code for the dataTable:
<h:form id="request">
<p:dataTable value="#{dataTableView.employeeList}" id="Employee" var="emp"
selection="#{dataTableView.selectedEmployees}" rowKey="#{emp.id}">
<p:ajax event="rowSelectCheckbox" listener="#{dataTableView.EnableInputText}" />
<p:ajax event="rowSelect" listener="#{dataTableView.EnableInputText}" />
<p:columnGroup type="header">
<p:row>
<p:column/>
<p:column headerText="ID"/>
<p:column headerText="Name"/>
<p:column headerText="Location"/>
<p:column headerText="Remarks"/>
</p:row>
</p:columnGroup>
<p:column selectionMode="multiple" style="width:2%;text-align:center"/>
<p:column headerText="ID">
<h:outputText value="#{emp.id}"/>
</p:column>
<p:column headerText="Name">
<h:outputText value="#{emp.name}"/>
</p:column>
<p:column headerText="Location">
<h:outputText value="#{emp.location}"/>
</p:column>
<p:column headerText="Remarks">
<h:inputText id="inputT1" value="#{emp.remarks}" disabled="#{emp.disable}"/>
</p:column>
</p:dataTable>
</h:form>
And the code in the backing bean:
private List<Student> employeeList = new ArrayList<Student>();
private List<Student> selectedEmployees;
private boolean disable=true;
public void EnableInputText(SelectEvent event) {
RequestContext context = RequestContext.getCurrentInstance();
for(int i=0;i<selectedEmployees.size();i++){
for(int j=0;j<employeeList.size();j++){
if(selectedEmployees.get(i).getId().equals(employeeList.get(j).getId()))
{
selectedEmployees.get(j).setDisable(false);
context.update("request:Employee:"+i+":inputT1");
//employeeList.get(j).setDisable(false);
}
}
}
}
Currently, I will be able to click on the checkbox but theinputText
will remain disabled and I will get the error:
java.lang.UnsupportedOperationException
Aucun commentaire:
Enregistrer un commentaire