You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Lewis <ch...@bellsouth.net> on 2008/08/08 21:39:49 UTC

T5: checkboxes for selecting a sub group of hibernate entities

Hello,

I have a collection of entities that need to be displayed in a form. A
user must be able to indicate any number of these entities in which they
have interest  by checking the box, and I'm at a bit of a loss at how to
handle this elegantly. I've dealt with a variable number of inputs
before, where I used a loop index to update values in a list by
implementing a faux property setter accessed by the loop, but that won't
work with checkboxes because they are boolean. Here's a quick summary:

I have a table PropertyTypes that has a few records (Condo, Single
Family, Land / Lot, etc). In a form I'd present all of these to the user
as check boxes, and they could select any number of them indicating
their interest:

[ x ] Condo
[ x ] Single Family
[   ] Land / Lot

The only way I can think to do this is back that selection by a
collection of booleans, and then compare that list to the list of
entities from the table assuming that the collection sizes are identical
and that the indexes correspond exactly. I don't feel like that is
elegant and am wondering if anyone has ideas on a cleaner / simpler way
of doing this. Thanks!

-- 
http://thegodcode.net


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: checkboxes for selecting a sub group of hibernate entities

Posted by Chris Lewis <ch...@bellsouth.net>.
Ok so I've made some progress after further reading, hacking, and
searching.What it comes down to is needing a PrimaryKeyEncoder so that
the entity collection can be serialized in the form loop. This raises
questions:

tapestry-hibernate provides a value encoder based on the primary keys of
entities, which is just great. Why can't this be applied to other
contexts like looping? I guess that would make the question, can
tapestry-hibernate also provide the same kind of implementation for
PrimaryKeyEncoder? The concept /seems/ identical.

Another, quite beaten question is why are there so many different ways
of (un)marshaling objects between the client and server sides? There's
been a lot of talk about this on the list and I'm not as concerned about
it at the moment as I am getting tapestry-hibernate to provide a PKE for
me. But given the fact taht I just declared a private final class to do
essentially the same thing as the included value encoder, I have to ask..

chris

Chris Lewis wrote:
> Hello,
>
> I have a collection of entities that need to be displayed in a form. A
> user must be able to indicate any number of these entities in which they
> have interest  by checking the box, and I'm at a bit of a loss at how to
> handle this elegantly. I've dealt with a variable number of inputs
> before, where I used a loop index to update values in a list by
> implementing a faux property setter accessed by the loop, but that won't
> work with checkboxes because they are boolean. Here's a quick summary:
>
> I have a table PropertyTypes that has a few records (Condo, Single
> Family, Land / Lot, etc). In a form I'd present all of these to the user
> as check boxes, and they could select any number of them indicating
> their interest:
>
> [ x ] Condo
> [ x ] Single Family
> [   ] Land / Lot
>
> The only way I can think to do this is back that selection by a
> collection of booleans, and then compare that list to the list of
> entities from the table assuming that the collection sizes are identical
> and that the indexes correspond exactly. I don't feel like that is
> elegant and am wondering if anyone has ideas on a cleaner / simpler way
> of doing this. Thanks!
>
>   

-- 
http://thegodcode.net


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org