You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Shawn Church <sh...@boxity.com> on 2004/04/19 16:48:39 UTC

Checkboxes

I'm 95% finished with my first Tapestry project, but I'm trying to 
clean up some of the rough edges.

I have an item list X which I am rendering as a checkbox selection 
within a Foreach on page PageX.  I also have a list Y which I am 
similarly rendering in PageY.  

The only problem I'm running into is that some of the Y items may also 
exist on the X list, and may have previously been user-selected on 
PageX.  When I show the PageY page, I want to show these previously-
selected items as disabled but selected checkboxes.  

This seems straight-forward, but I'm not sure how to best handle it in 
Tapestry.  I am currently setting my @Checkbox selected attribute if it 
was selected in the previous list.  However, both of these lists are 
persistent, and I end up with duplicate item selections, which I am 
trying to avoid.  The selected items are subsequently listed on 
an "items selected" sort of page, along with item prices.  Each of the 
pages also have running totals (calculated via JavaScript functions as 
the checkboxes are selected on each page).  

Every time I access the selected items in the Y list however, I always 
exclude any duplicate items which exist in the X list.  This is really 
error-prone and feels like a hack to Tapestry.  

The disabled attribute works fine, since it's based on the X list 
selection, but I would like to somehow treat the selected attribute 
similarly.  What I have (in effect) is this:

<input type="checkbox" jwcid="Partnumbers@Checkbox"
   selected="ognl:Y.selected"
   value="ognl:Y.PartNo"
   disabled="ognl:X.selected"
   onClick="UpdatePrice(this.form)"/>

but I would like to have this:

<input type="checkbox" jwcid="Partnumbers@Checkbox"
   selected="ognl:Y.selected or X.selected"
   value="ognl:Y.PartNo"
   disabled="ognl:X.selected"
   onClick="UpdatePrice(this.form)"/>

Is there a way to signal Tapestry to only render the checkbox for the 
page, but to not attempt to set the selection in my list when the form 
is rendered?  I thought of having the checkboxes enclosed within a 
Conditional and adding a second checkbox which is not part of the 
Tapestry @Form, but it still seems like a hack and results in more 
clutter.  Should I build a custom component?  Does something already 
exist?

Thanks,
Shawn


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


Re: Checkboxes

Posted by Shawn Church <sh...@boxity.com>.
I'm actually keeping everything in the Visit object, and it is working 
fine, but I'm not very happy with the design.  

I'm not exactly trying to use the first list in the second page; I'm 
actually presenting a different list which may have some common 
elements.  This application is a product configurator which has several 
pages of required items (for machine tooling), optional items, 
recommended accessories, general accessories, etc.

Since Tapestry is in control of processing the checkboxes during the 
form submit, I end up with items selected in both lists.  Normally this 
would be trivial, as I would just discard the duplicates when 
processing the form, but I'm not sure how to cause Tapestry to do that.

Part of the issue here relates to the thread currently on the list 
regarding page lifecycle.  If a user selects an item and submits, and 
then backs up to an earlier page in the browser cache to change some 
other option, I don't want to throw away everything else they have done 
beyond that point.  So, I am taking a lot of care to synchronize 
everything and to remember (via session state) what they have done.

Going back to the checkbox issue, if a user selects an item on one 
page, I want to reflect the selection in subsequent pages (but not 
actually make duplicate selections in the subsequent lists).  Since 
they can back-button to earlier pages, change their mind and de-select 
previous items, and then resubmit, the next page after that point 
should reflect the new selection state.  The care I am having to take 
is to ensure those de-selected items are also de-selected in the 
subsequent lists, which is dangerous.  It would be better if they were 
not redundantly selected to begin with.

Thanks,
Shawn


Quoting John Studarus <st...@jhlconsulting.com>:

> 
>   How about if you keep the list in a Visit
> object rather than two persistent objects?  Then
> keep track of the selection properties in that
> list in the Visit.  Build the lists in the first
> page, set them in the Visit and access them in the
> second page.  Seems like that would be the easiest fix.
> 
>         John
> 
> 
> On Mon, Apr 19, 2004 at 07:48:39AM -0700, Shawn Church wrote:
> > I'm 95% finished with my first Tapestry project, but I'm trying to
> 
> > clean up some of the rough edges.
> > 
> > I have an item list X which I am rendering as a checkbox selection
> 
> > within a Foreach on page PageX.  I also have a list Y which I am 
> > similarly rendering in PageY.  
> > 
> > The only problem I'm running into is that some of the Y items may
> also 
> > exist on the X list, and may have previously been user-selected on
> 
> > PageX.  When I show the PageY page, I want to show these
> previously-
> > selected items as disabled but selected checkboxes.  
> > 
> > This seems straight-forward, but I'm not sure how to best handle it
> in 
> > Tapestry.  I am currently setting my @Checkbox selected attribute
> if it 
> > was selected in the previous list.  However, both of these lists
> are 
> > persistent, and I end up with duplicate item selections, which I am
> 
> > trying to avoid.  The selected items are subsequently listed on 
> > an "items selected" sort of page, along with item prices.  Each of
> the 
> > pages also have running totals (calculated via JavaScript functions
> as 
> > the checkboxes are selected on each page).  
> > 
> > Every time I access the selected items in the Y list however, I
> always 
> > exclude any duplicate items which exist in the X list.  This is
> really 
> > error-prone and feels like a hack to Tapestry.  
> > 
> > The disabled attribute works fine, since it's based on the X list 
> > selection, but I would like to somehow treat the selected attribute
> 
> > similarly.  What I have (in effect) is this:
> > 
> > <input type="checkbox" jwcid="Partnumbers@Checkbox"
> >    selected="ognl:Y.selected"
> >    value="ognl:Y.PartNo"
> >    disabled="ognl:X.selected"
> >    onClick="UpdatePrice(this.form)"/>
> > 
> > but I would like to have this:
> > 
> > <input type="checkbox" jwcid="Partnumbers@Checkbox"
> >    selected="ognl:Y.selected or X.selected"
> >    value="ognl:Y.PartNo"
> >    disabled="ognl:X.selected"
> >    onClick="UpdatePrice(this.form)"/>
> > 
> > Is there a way to signal Tapestry to only render the checkbox for
> the 
> > page, but to not attempt to set the selection in my list when the
> form 
> > is rendered?  I thought of having the checkboxes enclosed within a
> 
> > Conditional and adding a second checkbox which is not part of the 
> > Tapestry @Form, but it still seems like a hack and results in more
> 
> > clutter.  Should I build a custom component?  Does something
> already 
> > exist?
> > 
> > Thanks,
> > Shawn
> > 
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> 




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


Re: Checkboxes

Posted by John Studarus <st...@jhlconsulting.com>.
  How about if you keep the list in a Visit
object rather than two persistent objects?  Then
keep track of the selection properties in that
list in the Visit.  Build the lists in the first
page, set them in the Visit and access them in the
second page.  Seems like that would be the easiest fix.

        John


On Mon, Apr 19, 2004 at 07:48:39AM -0700, Shawn Church wrote:
> I'm 95% finished with my first Tapestry project, but I'm trying to 
> clean up some of the rough edges.
> 
> I have an item list X which I am rendering as a checkbox selection 
> within a Foreach on page PageX.  I also have a list Y which I am 
> similarly rendering in PageY.  
> 
> The only problem I'm running into is that some of the Y items may also 
> exist on the X list, and may have previously been user-selected on 
> PageX.  When I show the PageY page, I want to show these previously-
> selected items as disabled but selected checkboxes.  
> 
> This seems straight-forward, but I'm not sure how to best handle it in 
> Tapestry.  I am currently setting my @Checkbox selected attribute if it 
> was selected in the previous list.  However, both of these lists are 
> persistent, and I end up with duplicate item selections, which I am 
> trying to avoid.  The selected items are subsequently listed on 
> an "items selected" sort of page, along with item prices.  Each of the 
> pages also have running totals (calculated via JavaScript functions as 
> the checkboxes are selected on each page).  
> 
> Every time I access the selected items in the Y list however, I always 
> exclude any duplicate items which exist in the X list.  This is really 
> error-prone and feels like a hack to Tapestry.  
> 
> The disabled attribute works fine, since it's based on the X list 
> selection, but I would like to somehow treat the selected attribute 
> similarly.  What I have (in effect) is this:
> 
> <input type="checkbox" jwcid="Partnumbers@Checkbox"
>    selected="ognl:Y.selected"
>    value="ognl:Y.PartNo"
>    disabled="ognl:X.selected"
>    onClick="UpdatePrice(this.form)"/>
> 
> but I would like to have this:
> 
> <input type="checkbox" jwcid="Partnumbers@Checkbox"
>    selected="ognl:Y.selected or X.selected"
>    value="ognl:Y.PartNo"
>    disabled="ognl:X.selected"
>    onClick="UpdatePrice(this.form)"/>
> 
> Is there a way to signal Tapestry to only render the checkbox for the 
> page, but to not attempt to set the selection in my list when the form 
> is rendered?  I thought of having the checkboxes enclosed within a 
> Conditional and adding a second checkbox which is not part of the 
> Tapestry @Form, but it still seems like a hack and results in more 
> clutter.  Should I build a custom component?  Does something already 
> exist?
> 
> Thanks,
> Shawn
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org

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


Re: Checkboxes

Posted by Jamie Orchard-Hays <ja...@dang.com>.
you might also have a look at contrib:MultiplePropertySelection. It can
render checkboxes instead of selects.


----- Original Message ----- 
From: "Shawn Church" <sh...@boxity.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Monday, April 19, 2004 10:48 AM
Subject: Checkboxes


> I'm 95% finished with my first Tapestry project, but I'm trying to
> clean up some of the rough edges.
>
> I have an item list X which I am rendering as a checkbox selection
> within a Foreach on page PageX.  I also have a list Y which I am
> similarly rendering in PageY.
>
> The only problem I'm running into is that some of the Y items may also
> exist on the X list, and may have previously been user-selected on
> PageX.  When I show the PageY page, I want to show these previously-
> selected items as disabled but selected checkboxes.
>
> This seems straight-forward, but I'm not sure how to best handle it in
> Tapestry.  I am currently setting my @Checkbox selected attribute if it
> was selected in the previous list.  However, both of these lists are
> persistent, and I end up with duplicate item selections, which I am
> trying to avoid.  The selected items are subsequently listed on
> an "items selected" sort of page, along with item prices.  Each of the
> pages also have running totals (calculated via JavaScript functions as
> the checkboxes are selected on each page).
>
> Every time I access the selected items in the Y list however, I always
> exclude any duplicate items which exist in the X list.  This is really
> error-prone and feels like a hack to Tapestry.
>
> The disabled attribute works fine, since it's based on the X list
> selection, but I would like to somehow treat the selected attribute
> similarly.  What I have (in effect) is this:
>
> <input type="checkbox" jwcid="Partnumbers@Checkbox"
>    selected="ognl:Y.selected"
>    value="ognl:Y.PartNo"
>    disabled="ognl:X.selected"
>    onClick="UpdatePrice(this.form)"/>
>
> but I would like to have this:
>
> <input type="checkbox" jwcid="Partnumbers@Checkbox"
>    selected="ognl:Y.selected or X.selected"
>    value="ognl:Y.PartNo"
>    disabled="ognl:X.selected"
>    onClick="UpdatePrice(this.form)"/>
>
> Is there a way to signal Tapestry to only render the checkbox for the
> page, but to not attempt to set the selection in my list when the form
> is rendered?  I thought of having the checkboxes enclosed within a
> Conditional and adding a second checkbox which is not part of the
> Tapestry @Form, but it still seems like a hack and results in more
> clutter.  Should I build a custom component?  Does something already
> exist?
>
> Thanks,
> Shawn
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


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