selectBooleanCheckbox and entity deletion in DB
Hi,
In HtmlDataTable i am displaying entities from DB , and i am associating a checkBox to each entity(dynamic for n nuber of entities), when user select on a check box that corresponding entity i have to capture in Backing bean to make deletion.
There is no relation ship between checkbox and entity displayed in data table( i can't associate coz im getting Data Layer from another person). is there any way to do this .
[441 byte] By [
veerjaa] at [2007-11-27 1:33:35]

# 1
Extend the DTO with your own class and add the boolean property to it.
public class MyDto extends AnotherPersonDto {
boolean selected; // + getter (isser) + setter
}
Then use List<MyDto> instead of List<AnotherPersonDto> in your webapp.
# 2
im getting this excetion when doing like u said in jsf page
javax.servlet.ServletException: javax.servlet.jsp.JspException: java.lang.IllegalArgumentException: argument type mismatch
before my data table
<h:dataTable id="my_docs" value="#{ManageDocument.listOfDocuments}" binding="#{ManageDocument.markedForDeletion}" var="myDocItem" bgcolor="silver">
<h:column>
<f:facet name="header"> <h:outputText value="Select" />
</f:facet>
<h:selectBooleanCheckbox>
</h:selectBooleanCheckbox>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="File Name" style="font-size:smaller;width:150px;" />
</f:facet>
<h:outputText value="#{myDocItem.fileName}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="File Size" style="font-size:smaller;width:150px" />
</f:facet>
<h:outputText value="#{myDocItem.fileSize}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Date Uploaded" style="font-size:smaller;width:150px"/>
</f:facet>
<h:outputText value="#{myDocItem.dateFileUploaded}" />
</h:column>
</h:dataTable>
after ur suggesion
<h:dataTable id="my_docs" value="#{ManageDocument.listOfDocuments}" binding="#{ManageDocument.markedForDeletion}" var="myDocItem" bgcolor="silver">
<h:column>
<f:facet name="header"> <h:outputText value="Select" />
</f:facet>
<h:selectBooleanCheckbox binding="#{uidocument.selected}">
</h:selectBooleanCheckbox>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="File Name" style="font-size:smaller;width:150px;" />
</f:facet>
<h:outputText value="#{myDocItem.fileName}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="File Size" style="font-size:smaller;width:150px" />
</f:facet>
<h:outputText value="#{myDocItem.fileSize}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Date Uploaded" style="font-size:smaller;width:150px"/>
</f:facet>
<h:outputText value="#{myDocItem.dateFileUploaded}" />
</h:column>
</h:dataTable>
and in backing table the Binding with HtmlDataTable.
before ur suggesion mydataTable value attribute is value="#{ManageDocument.listOfDocuments}" ,
which arrayList of Documents
after ur suggesion it is arrayList of MyDcouments
# 3
<h:selectBooleanCheckbox binding="#{uidocument.selected}">
this should be
<h:selectBooleanCheckbox value="#{myDocItem.selected}" />
Also see the CRUD example in the EAR provided here: http://balusc.xs4all.nl/srv/dev-jep-dat.html
Accidently, the MyCrudData DTO there also extends the MyData DTO, exactly the same way as you need it.