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.

BalusCa at 2007-7-12 0:39:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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

veerjaa at 2007-7-12 0:39:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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.

BalusCa at 2007-7-12 0:39:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
When i changed to <h:selectBooleanCheckbox binding="#{myDocItem.selected}">im getting exceptionjavax.servlet.ServletException: javax.servlet.jsp.JspException: Error setting property 'selected' in bean of type null
veerjaa at 2007-7-12 0:39:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Value. Not binding.Do you understand the difference between them anyway?
BalusCa at 2007-7-12 0:39:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
but the value attribute of HtmlDataTable refers to a list(ArrayList) whose objects are of type MyDocument.
veerjaa at 2007-7-12 0:39:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

So?

Face it: MyDocument#selected refers to a boolean, not to an UIComponent (HtmlSelectBooleanCheckbox, in this case).

This does not give the suitable answer, but this might provide insights in the difference between "binding" and "value": http://balusc.xs4all.nl/srv/dev-jep-djl.html

BalusCa at 2007-7-12 0:39:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
Hi i got it as you said finally. but there is lot memory is required i(for populating objects in arrayList for each refresh ). f we are going to upload multiple files and to show them in the same screen.and how to make it synchronize for multiple users
veerjaa at 2007-7-12 0:39:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...