You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by David Leangen <dl...@canada.com> on 2005/04/05 05:58:28 UTC

RE: Duplicate controls in form

Pieter,

This is brilliant! Very simple and elegant. Exactly the type of solution I
was looking for, given that there is no built-in mechanism for multiple
components.

Thanks a lot for following up on this! :-)


Cheers,
Dave


PS - I replied to the list because this could be useful for others.




> -----Original Message-----
> From: Pieter Schoenmakers [mailto:pieter.schoenmakers@aspiratie.nl]
> Sent: 5 April 2005 05:23
> To: dleangen@canada.com
> Subject: RE: Duplicate controls in form
>
>
> Dave,
> Add a hidden field with the same value.  Then you have three voters.  On
> submit, the odd one out is the input that changed.
> Pieter
>
>
> > -----Original Message-----
> > From: David Leangen [mailto:dleangen@canada.com]
> > Sent: Monday, March 14, 2005 10:46 AM
> > To: Tapestry users
> > Subject: RE: Duplicate controls in form
> >
> >
> > Hi, Ron,
> >
> > Yeah, I thought about that. The thing I don't like about it
> > is that the site becomes depending on Javascript.
> >
> > In other words, I don't mind using Javascript as a "bonus"
> > where people who enable it can get some extra functionality.
> > However, since a lot of our users don't or can't use
> > Javascript for various reasons, making it a requirement is
> > not really an option.
> >
> >
> > So, IIUC, you're saying that there's no real "elegant" way to
> > do this, other than adding more clutter to my code?
> >
> >
> >
> > Cheers,
> > Dave
> >
> >
> >
> >
> >
> > > -----Original Message-----
> > > From: ron [mailto:ron.piterman@gmx.net]
> > > Sent: 14 March 2005 18:42
> > > To: Tapestry users
> > > Subject: Re: Duplicate controls in form
> > >
> > >
> > > What about useing java script to change a hidden field when
> > one of them
> > > change? The value in the actual controls will be ignored.
> > This should
> > > not be very heavy scripting.
> > > Cheers,
> > > Ron
> > >
> > >
> > > ????? David Leangen:
> > >
> > > >Hi, Ron,
> > > >
> > > >Good idea... the only problem is that the form is very complex
> > > (which is why this control appears twice... just to make sure it
> > > doesn't get missed). So, we would have to duplicate everything
> > > else, to, which is not really what we want.
> > > >
> > > >
> > > >Cheers,
> > > >Dave
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >>-----Original Message-----
> > > >>From: ron [mailto:ron.piterman@gmx.net]
> > > >>Sent: 14 March 2005 18:26
> > > >>To: Tapestry users
> > > >>Subject: Re: Duplicate controls in form
> > > >>
> > > >>
> > > >>What about using a different form for each one?
> > > >>When you submit, only one form get submitted - thus only
> > one value will
> > > >>pass through?
> > > >>
> > > >>
> > > >>????? David Leangen:
> > > >>
> > > >>
> > > >>
> > > >>>Thanks for the tip, Ron.
> > > >>>
> > > >>>However, what you wrote is exactly the same thing that I did
> > > >>>
> > > >>>
> > > >>(see below). As I mentioned, this doesn't work well because the
> > > >>two components refer to the same variable. It appears that only
> > > >>the "last" one is accepted, so if the two values are different,
> > > >>the behaviour is not what is desired.
> > > >>
> > > >>
> > > >>>For instance, suppose that the control in question is a
> > drop-down list:
> > > >>>
> > > >>>+-------+
> > > >>>|value 1|
> > > >>>+-------+
> > > >>>|value 1|
> > > >>>|value 2|
> > > >>>+-------+
> > > >>>
> > > >>>(This is supposed to represent a drop-down list with the values
> > > >>>
> > > >>>
> > > >>"value 1" and "value 2", with "value 1" currently selected.
> > > >>
> > > >>
> > > >>>Now, when the user changes the top control to "value 2",
> > we get this:
> > > >>>
> > > >>>
> > > >>>TOP
> > > >>>+-------+
> > > >>>|value 2|
> > > >>>+-------+
> > > >>>|value 1|
> > > >>>|value 2|
> > > >>>+-------+
> > > >>>
> > > >>>BOTTOM
> > > >>>+-------+
> > > >>>|value 1|
> > > >>>+-------+
> > > >>>|value 1|
> > > >>>|value 2|
> > > >>>+-------+
> > > >>>
> > > >>>
> > > >>>The user will obviously expect the results to be "value 2",
> > > >>>
> > > >>>
> > > >>however this is not what happens, since "value 1" from the bottom
> > > >>control is taking precedence.
> > > >>
> > > >>
> > > >>>
> > > >>>I can see a few workarounds:
> > > >>>
> > > >>>1. Have a separate variable (i.e. do not use "copy-of"). I don't
> > > >>>
> > > >>>
> > > >>like this, though, because it adds more clutter to the code.
> > > >>
> > > >>
> > > >>>2. Insert a javascript so that when the top control changes, the
> > > >>>
> > > >>>
> > > >>bottom control will also change. I don't like this, since I don't
> > > >>want to have to implement javascript and I especially don't want
> > > >>to have to depend on the javascript to make the
> > functionality work.
> > > >>
> > > >>
> > > >>>
> > > >>>So, what I'm wondering, I guess, is if anybody has any
> > > >>>
> > > >>>
> > > >>suggestions for a more elegant solution?
> > > >>
> > > >>
> > > >>>Thanks so much!
> > > >>>
> > > >>>Dave
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>>-----Original Message-----
> > > >>>>From: ron [mailto:mplayer@vollbio.de]
> > > >>>>Sent: 14 March 2005 00:44
> > > >>>>To: Tapestry users
> > > >>>>Subject: Re: Duplicate controls in form
> > > >>>>
> > > >>>>
> > > >>>>Using twice the same component is not possible.
> > > >>>>
> > > >>>>In your page/component definition you should use:
> > > >>>>
> > > >>>><component id="selectPresentationFormatTop" ...
> > > >>>></component>
> > > >>>>
> > > >>>><component id="id="selectPresentationFormatTop2"
> > > >>>>copy-of="selectPresentationFormatTop"/>
> > > >>>>
> > > >>>>then use once the first, once the second.
> > > >>>>
> > > >>>>Cheers,
> > > >>>>Ron
> > > >>>>
> > > >>>>
> > > >>>>????? David Leangen:
> > > >>>>
> > > >>>>
> > > >>>>
> > > >>>>
> > > >>>>
> > > >>>>>I have a page that has duplicate controls in a form.
> > > >>>>>
> > > >>>>>
> > > >>Specifically, I have
> > > >>
> > > >>
> > > >>>>>these two dropdowns in my HTML:
> > > >>>>>
> > > >>>>><form jwcid="@Form">
> > > >>>>>
> > > >>>>>  <select jwcid="selectPresentationFormatTop">
> > > >>>>>    <option selected value="1">Format 1</option>
> > > >>>>>    <option value="2">Format 2</option>
> > > >>>>>  </select>
> > > >>>>>
> > > >>>>>  <select jwcid="selectPresentationFormatTop">
> > > >>>>>    <option selected value="1">Format 1</option>
> > > >>>>>    <option value="2">Format 2</option>
> > > >>>>>  </select>
> > > >>>>>
> > > >>>>></form>
> > > >>>>>
> > > >>>>>
> > > >>>>>
> > > >>>>>In my page file, I have this:
> > > >>>>>
> > > >>>>><component id="selectPresentationFormatTop"
> > type="PropertySelection">
> > > >>>>>  <binding name="model"
> > > >>>>>
> > > >>>>>
> > > >>expression="presentationFormatSelectionModel"/>
> > > >>
> > > >>
> > > >>>>>  <binding name="value" expression="presentationFormat"/>
> > > >>>>></component>
> > > >>>>>
> > > >>>>><component id="selectPresentationFormatBottom"
> > > >>>>>copy-of="selectPresentationFormatTop"/>
> > > >>>>>
> > > >>>>><property-specification
> > > >>>>>  name="presentationFormat"
> > > >>>>>  persistent="yes"
> > > >>>>>  type="com.company.type.KPresentationFormat"/>
> > > >>>>>
> > > >>>>>
> > > >>>>>I've now realized that even when a user changes the top
> > > >>>>>
> > > >>>>>
> > > >>contol, it has no
> > > >>
> > > >>
> > > >>>>>effect on the results, since because of the ordering of the
> > > >>>>>
> > > >>>>>
> > > >>controls, the
> > > >>
> > > >>
> > > >>>>>value of the bottom control will always be used.
> > > >>>>>
> > > >>>>>
> > > >>>>>I can think of several ways to make this work, but I'm
> > wondering
> > > >>>>>
> > > >>>>>
> > > >>>>>
> > > >>>>>
> > > >>>>if (1) the
> > > >>>>
> > > >>>>
> > > >>>>
> > > >>>>
> > > >>>>>framework provides for this situation, or (2) anybody has any
> > > >>>>>
> > > >>>>>
> > > >>suggestions
> > > >>
> > > >>
> > > >>>>>for an elegant solution.
> > > >>>>>
> > > >>>>>
> > > >>>>>
> > > >>>>>Thank you!
> > > >>>>>David
> > > >>>>>
> > > >>>>>
> > >
> > >>>>>---------------------------------------------------------
> > ------------
> > > >>>>>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
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > >
> > >>------------------------------------------------------------
> > ---------
> > > >>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
> > >
> >
> >
> > ---------------------------------------------------------------------
> > 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