-
1. Re: Checkbox\Datatable help w\Seamgen
norman Apr 2, 2008 12:57 AM (in response to thatproblemguy)The basic idea in the DVD Store is that instead of creating view objects with a property indicating the item is selected, you can map a checkbox to a boolean in a Map indexed by the item in questions. So, you'll see things like:
<h:selectBooleanCheckbox value="#{cart.cartSelection[item]}"/>
cartSelection is being backed by a simple map:
Map<Product,Boolean> cartSelection = new HashMap<Product,Boolean>();
That map gets updated whenever the form is submitted. It's a fairly simply process to iterate over the map and find out what the selected objects are. In this particular case, the updateCart() method iterates through the known items and checks which are marked as selected. Take a look at search.addAllToCart for another use.
-
2. Re: Checkbox\Datatable help w\Seamgen
thatproblemguy Apr 2, 2008 5:17 PM (in response to thatproblemguy)I guess I don't understand very well. The examples aren't very clear for something that was kicked off with seamgen. Which object does the Map go into (the list or home object)? Do those have to be marked as @Stateful then? I'm just lost trying to match up a seamgened app to everything else. I'm still trying to wrap my head around how this whole thing works.
Thanks.
-
3. Re: Checkbox\Datatable help w\Seamgen
norman Apr 2, 2008 6:06 PM (in response to thatproblemguy)It doesn't really matter where the Map goes. I think the most convenient place to put it is on whatever component has the action that will be using the data. Where do you want to be performing an action that uses the the selected objects?
-
4. Re: Checkbox\Datatable help w\Seamgen
thatproblemguy Apr 3, 2008 2:27 AM (in response to thatproblemguy)Ok, stupid question then... does the action have to be a Session bean?
-
5. Re: Checkbox\Datatable help w\Seamgen
thatproblemguy Apr 3, 2008 4:37 PM (in response to thatproblemguy)Ok, don't mind me. I tried on a different project and it worked fine. I'm not sure why it doesn't work on the original project yet though. Thanks for your help.
-
6. Re: Checkbox\Datatable help w\Seamgen
karan Dec 15, 2008 8:42 AM (in response to thatproblemguy)Hi smith I am also looking for one such example which you were looking for, can you post your sample code to select multiple rows in the datatable using checkboxes and delete them all in just one click of delete button.
\ 01. Apr 2008, 20:38 CET Link
JC Smith
However, we are trying to add checkboxes to the datatables so teh user can select multiple items and then delete everything in one click. How exactly do we go about that? I thought it would be very common and I've looked at the Dvd store example for help, but I'm missing something on how you tie together the submit with the checkboxes. The stuff already posted on this problem hasn't been much help.
Thanks, TPGThank You
Karan