You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Petri Wessman <or...@iki.fi> on 2008/01/07 12:31:29 UTC

[tapestry 4.0.2] how to do variable number of checkboxes?

Hello all, using Tapestry 4.0.2 here (had some Javascript issues when 
trying to upgrade to 4.1.x, so putting off upgrading till I figure those 
out). Anyway, I'm now trying to implement a new functionality to our app 
and am a bit puzzled as to the best way to do it.

What I want to do is have a list of items (0-N items), and a checkbox 
next to each one (i.e. one checkbox per line item). Below this list I'll 
have controls to "delete all checked items" (or in general, "do X to 
checked items"). Pretty basic UI functionality... except that I'm 
stumped as how to do it with Tapestry.

I'm generating the list with a normal @For loop, and that works fine. 
The checkboxes I need some help on, though... how do I bind a list of 
checkboxes to values, so that I can figure out which one is related to 
which line item on form submit?

All help appreciated. If it requires upgrading to 4.1.x, then that's 
doable too, with some extra work.

//Petri

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


Re: PropertySelection request

Posted by Andreas Andreou <an...@gmail.com>.
http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/form/IPropertySelectionModel.html
and
http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/form/LabeledPropertySelectionModel.html

On Jan 10, 2008 5:25 PM, Tobias Marx <su...@gmx.de> wrote:
> A quick but useful feature suggestion for the default PropertySelection:
>
> optional="true/false"
>
> Which would automatically add an empty item ad the beginning, for the
> case it is an optional PropertySelection.
>
> Thanks!
>
> Tobias
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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


PropertySelection request

Posted by Tobias Marx <su...@gmx.de>.
A quick but useful feature suggestion for the default PropertySelection:

optional="true/false"

Which would automatically add an empty item ad the beginning, for the
case it is an optional PropertySelection.

Thanks!

Tobias

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


Re: [tapestry 4.0.2] how to do variable number of checkboxes?

Posted by Petri Wessman <or...@iki.fi>.
Andreas Andreou wrote:
> Well, there are some options here...
> 
> Try removing
> public abstract boolean getSomeValue();
> and use
> 
> public boolean getSomeValue() {
> // return the correct value using getCurrentListItem()
> }
> 
> public void setSomeValue(boolean value) {
> // store the value using getCurrentListItem()
> }

Ah, of course. Must be lack of coffee making me dumb today. :}.

Thanks a lot for the help, I'm all set now.

//Petri

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


Re: [tapestry 4.0.2] how to do variable number of checkboxes?

Posted by Andreas Andreou <an...@gmail.com>.
Well, there are some options here...

Try removing
public abstract boolean getSomeValue();
and use

public boolean getSomeValue() {
// return the correct value using getCurrentListItem()
}

public void setSomeValue(boolean value) {
// store the value using getCurrentListItem()
}


On Jan 7, 2008 2:38 PM, Petri Wessman <or...@iki.fi> wrote:
> Andreas Andreou wrote:
> > Hi, what's the problem with just binding the value parameter of
> > http://tapestry.apache.org/tapestry4.1/components/form/checkbox.html ?
>
> Well, the question becomes "what do I bind it to?". Up to now, I've been
> using a static number of checkboxes per page, and each one has been
> given an OGNL property as value, e.g.:
>
> <input type="checkbox" jwcid="@Checkbox" value="ognl:someValue"/>
>
> with the code having:
>
> public abstract boolean getSomeValue();
>
> In this case, I have a variable number of checkboxes per page, I'd need
> to bind them to array elements (I guess) or some such. How do I do that
> in OGNL?
>
> As a simplified concrete example, I'd have something like this on the page:
>
> <table>
> <div jwcid="@For" source="ognl:itemList" value="ognl:currentListItem">
>    <tr>
>      <td><span jwcid="@Insert" value="ognl:currentListItem.name"/></td>
>      <td><input type="checkbox" jwcid="@Checkbox" value="???"/></td>
>    </tr>
> </div>
> </table>
>
> What goes in "???" ?
>
> Sorry if I'm missing something obvious here, but so far RTFM hasn't
> clued me in sufficiently :/.
>
> //Petri
>
>
> > On Jan 7, 2008 1:31 PM, Petri Wessman <or...@iki.fi> wrote:
> >> Hello all, using Tapestry 4.0.2 here (had some Javascript issues when
> >> trying to upgrade to 4.1.x, so putting off upgrading till I figure those
> >> out). Anyway, I'm now trying to implement a new functionality to our app
> >> and am a bit puzzled as to the best way to do it.
> >>
> >> What I want to do is have a list of items (0-N items), and a checkbox
> >> next to each one (i.e. one checkbox per line item). Below this list I'll
> >> have controls to "delete all checked items" (or in general, "do X to
> >> checked items"). Pretty basic UI functionality... except that I'm
> >> stumped as how to do it with Tapestry.
> >>
> >> I'm generating the list with a normal @For loop, and that works fine.
> >> The checkboxes I need some help on, though... how do I bind a list of
> >> checkboxes to values, so that I can figure out which one is related to
> >> which line item on form submit?
> >>
> >> All help appreciated. If it requires upgrading to 4.1.x, then that's
> >> doable too, with some extra work.
> >>
> >> //Petri
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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


Re: [tapestry 4.0.2] how to do variable number of checkboxes?

Posted by Petri Wessman <or...@iki.fi>.
Petri Wessman wrote:
> As a simplified concrete example, I'd have something like this on the page:
> 
> <table>
> <div jwcid="@For" source="ognl:itemList" value="ognl:currentListItem">
>   <tr>
>     <td><span jwcid="@Insert" value="ognl:currentListItem.name"/></td>
>     <td><input type="checkbox" jwcid="@Checkbox" value="???"/></td>
>   </tr>
> </div>
> </table>
> 
> What goes in "???" ?

Replying to myself here :).

I just occurred to me that I could (naturally) store the "checked" value 
  into the current line item itself, with something like 
"ognl:currentListItem.checked". Doh! I was using read-only values when 
playing around with this, but there's nothing stopping me making a temp 
read/write version of the item list here.

For the sake of academic interest: if for some weird reason I could not 
store the value into the current For-loop item itself, how would I do 
this? In other words, if I wanted to use a decoupled array of booleans 
(or some such), is there an OGNL notation or some other trick with which 
I could bind the checkbox value to an array element?

//Petri

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


Re: [tapestry 4.0.2] how to do variable number of checkboxes?

Posted by Petri Wessman <or...@iki.fi>.
Andreas Andreou wrote:
> Hi, what's the problem with just binding the value parameter of
> http://tapestry.apache.org/tapestry4.1/components/form/checkbox.html ?

Well, the question becomes "what do I bind it to?". Up to now, I've been 
using a static number of checkboxes per page, and each one has been 
given an OGNL property as value, e.g.:

<input type="checkbox" jwcid="@Checkbox" value="ognl:someValue"/>

with the code having:

public abstract boolean getSomeValue();

In this case, I have a variable number of checkboxes per page, I'd need 
to bind them to array elements (I guess) or some such. How do I do that 
in OGNL?

As a simplified concrete example, I'd have something like this on the page:

<table>
<div jwcid="@For" source="ognl:itemList" value="ognl:currentListItem">
   <tr>
     <td><span jwcid="@Insert" value="ognl:currentListItem.name"/></td>
     <td><input type="checkbox" jwcid="@Checkbox" value="???"/></td>
   </tr>
</div>
</table>

What goes in "???" ?

Sorry if I'm missing something obvious here, but so far RTFM hasn't 
clued me in sufficiently :/.

//Petri

> On Jan 7, 2008 1:31 PM, Petri Wessman <or...@iki.fi> wrote:
>> Hello all, using Tapestry 4.0.2 here (had some Javascript issues when
>> trying to upgrade to 4.1.x, so putting off upgrading till I figure those
>> out). Anyway, I'm now trying to implement a new functionality to our app
>> and am a bit puzzled as to the best way to do it.
>>
>> What I want to do is have a list of items (0-N items), and a checkbox
>> next to each one (i.e. one checkbox per line item). Below this list I'll
>> have controls to "delete all checked items" (or in general, "do X to
>> checked items"). Pretty basic UI functionality... except that I'm
>> stumped as how to do it with Tapestry.
>>
>> I'm generating the list with a normal @For loop, and that works fine.
>> The checkboxes I need some help on, though... how do I bind a list of
>> checkboxes to values, so that I can figure out which one is related to
>> which line item on form submit?
>>
>> All help appreciated. If it requires upgrading to 4.1.x, then that's
>> doable too, with some extra work.
>>
>> //Petri
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> 


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


Re: [tapestry 4.0.2] how to do variable number of checkboxes?

Posted by Andreas Andreou <an...@gmail.com>.
Hi, what's the problem with just binding the value parameter of
http://tapestry.apache.org/tapestry4.1/components/form/checkbox.html ?

On Jan 7, 2008 1:31 PM, Petri Wessman <or...@iki.fi> wrote:
> Hello all, using Tapestry 4.0.2 here (had some Javascript issues when
> trying to upgrade to 4.1.x, so putting off upgrading till I figure those
> out). Anyway, I'm now trying to implement a new functionality to our app
> and am a bit puzzled as to the best way to do it.
>
> What I want to do is have a list of items (0-N items), and a checkbox
> next to each one (i.e. one checkbox per line item). Below this list I'll
> have controls to "delete all checked items" (or in general, "do X to
> checked items"). Pretty basic UI functionality... except that I'm
> stumped as how to do it with Tapestry.
>
> I'm generating the list with a normal @For loop, and that works fine.
> The checkboxes I need some help on, though... how do I bind a list of
> checkboxes to values, so that I can figure out which one is related to
> which line item on form submit?
>
> All help appreciated. If it requires upgrading to 4.1.x, then that's
> doable too, with some extra work.
>
> //Petri
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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