As Sebastian points out if the boolean selected field is part of your pojo it is trivial to bind this to a checkbox in the grid. This was my initial approach for simplicity but in my case the pojos were Hibernate entities and I didn't want this field to be persisted or to clutter up the entity as a transient field, so I went with a different approach which might work for you...
I created a session-persisted hashset in my page where the elements are the ids of the entities being selected (you can use the items themselves if they support hashcode/equals properly). My code looked something like this: MyPage.java ----------- private HashSet<String> selectedSet=new HashSet<String>(); public boolean getCurrentSelected() { return selectedSet.contains(current.getId()); } public void setCurrentSelected(boolean value) { if ( value ) { selectedSet.add(current.getId()); } else { selectedSet.remove(current.getId()); } } MyPage.tml ---------- <t:grid t:id="selectProgrammesGrid" source="availsList" row="current" add="select"> <p:selectcell> <t:checkbox value="currentSelected"/> </p:selectcell> </t:grid> Hope it helps, I thought it was rather tidy! Alfie. -----Original Message----- From: Scot Mcphee [mailto:scot.mcp...@gmail.com] Sent: 10 August 2009 06:41 To: users@tapestry.apache.org Subject: Using a checkbox in a grid component Hello Does any one have a short recipe how to use a checkbox in a grid component? What I need to do is fairly simple - let the use select (for example) three of five available options presented in a grid component, and submit their selections, which are then processed. A good example would be a "remove" checkbox on a list of items in a shopping cart, where the items are are only in the user's session so database IDs won't do. I've tried looking through the wiki, searching google, searching the mailing list with google, and looking through the 'Tapestry 5 Building Web Applications' book which I bought as a PDF, but alas, I can't find find a simple recipe for doing this. I'd like to use the Grid because the data will be fairly complex (it isn't for the time being, once I get this technique functional it will be). I'd like the selection to change a value in the underlying POJO (e.g. Pojo.selected) that's backing the Grid. I have been unable to get this anywhere near any semblance of "working". Therefore currently any sort of technique that could possibly work would be appreciated, for example to have an List<Pojo> originalList and List<Pojo> selectedList - I've tried to see what convention might give me that behaviour but so far, been unable to uncover it. scot --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org