Hi Damar,
I think one way to do this is write a simple class:
public class SelectableApplicant {
private boolean isSelected;
private Applicant applicant;
// add getters/setters for above
}
Change applicationProcess.applicants to return a list of
SelectableApplicant rather than Applicant directly.
Your JSP columns can be:
<h:column>
<t:selectBooleanCheckbox .. value="#{application.selected}"/>
</h:column>
<h:column>
<h:outputText value="#{application.applicant.firstName}"/>
</h:column>
etc.
Obviously, you can now iterate over the rows in the data model, checking
the boolean flag and if set processing the associated applicant object.
Regards,
Simon
Damar Thapa wrote:
Hi,
Thanks for your help – truly appreciated.
Now, I am in the last stage of this problem, ie I have to save the
data from the dataTable into a new file and in new Class structure. It
may be straight forward, anyway, I explain what I am trying to do.
The following is the snapshot of my dataTable:
<t:dataTable id="applicantsData"
……
……
var="application"
value="#{applicationProcess.applications}"
border="1"
preserveDataModel="false">
<h:column>
<f:facet name="header"><h:outputText value="Selected"/></f:facet>
<t:selectBooleanCheckbox forceId="true" id="chk"
onclick="onChangeSelect(this);"
value="#{applicationProcess.selected}"/>
</h:column>
<h:column>
<f:facet name="header"><h:outputText value="First Name"/></f:facet>
<h:outputText value="#{application.firstName}"/>
</h:column>
Surname,
Class
….
</t:dataTable>
The dataTable is using applicationProcess.applications list, which is
a list of Applicant object. Applicant Object has firstName, surname,
class, etc. and I have added <t:selectBooleanCheckBox> to determine if
the individual applicants are selected (and its value ie
applicationProcess.selected is not the property of Applicant Class).
What I have to do is iterate on the rows of dataTable and if the
<selectBooleanCheckbox> is checked, put it in another List. How can I
do this?
In the following,say:
public void saveData(ActionEvent event){
FacesContect context=FacesContext.getCurrentInstance();
List aList=event.getComponent()…..
…..
In the above, does event returns List from the dataTable? The value
of <selectBooleanCheckbox> ie applicationProcess.selected is not the
property of <Applicant> class, is it going to be the problem>
Any pointers would be highly appreciated, and sorry for lengthy and
too novice questions.
With regards,
Damar