You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Richard Hill <ri...@su3analytics.com> on 2011/02/07 10:30:31 UTC
How to fix the id attribute of a select component
Hi All,
I have a select component in a block:
<t:select t:type="select" t:id="cctEditSelect" t:blankOption="NEVER"
onchange="_SU3.renderWebOptions();"/>
The block is the second of three. The switching between them is
accomplished with an ajax actionlink request and a <t:delegate to />
By default the first block is shown on page load. If I then switch to
the second block, the id attribute of the <t:select> is something like:
id="cctEditSelect_947gyh0"
My onchange javascript function expects this to be simply
"cctEditSelect". If I refresh the whole page, then the id _is_ rendered
just "cctEditSelect" (the currently visible block is @Persist'd). It's
only when switching from another block do I get the random characters
appended.
I'm guessing this is to do with Tapestry making sure there are no id
conflicts. I have tried to force the id, by putting in my .java:
@InjectComponent
@Id("cctEditSelect")
private Select cctEditSelect;
But no juice - I get the same behaviour. How can I fix this id
attribute?
Many thanks,
Richard.
Re: How to fix the id attribute of a select component
Posted by Richard Hill <ri...@su3analytics.com>.
Hi Mark - the element only occurs in one block, so this shouldn't be an
issue I think.
R.
On Tue, 2011-02-08 at 11:48 -0600, Mark wrote:
> On Tue, Feb 8, 2011 at 9:36 AM, Richard Hill <ri...@su3analytics.com> wrote:
> >
> > Sure. But in my case I have only the one element, it's static in .tml
> > and not rendered in a loop.
> >
> > I think maybe what's causing it is that the element (t:select) is
> > contained within the zone it updates.
>
> If I understand your setup, you have three blocks that contain the
> same id. You use zones to show them one at a time. However, I don't
> think there is a way for Tapestry to know that you won't show two or
> more at a time and because of this it generates a unique id for each
> one.
>
> Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: How to fix the id attribute of a select component
Posted by Mark <ma...@xeric.net>.
On Tue, Feb 8, 2011 at 9:36 AM, Richard Hill <ri...@su3analytics.com> wrote:
>
> Sure. But in my case I have only the one element, it's static in .tml
> and not rendered in a loop.
>
> I think maybe what's causing it is that the element (t:select) is
> contained within the zone it updates.
If I understand your setup, you have three blocks that contain the
same id. You use zones to show them one at a time. However, I don't
think there is a way for Tapestry to know that you won't show two or
more at a time and because of this it generates a unique id for each
one.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: How to fix the id attribute of a select component
Posted by Richard Hill <ri...@su3analytics.com>.
Yeah this is a bit heavy for a simple select (for me anyway). My
workaround is to use the name attribute.
Cheers
On Tue, 2011-02-08 at 08:22 -0800, LLTYK wrote:
> The current "solution" is to use a mixin instead of onchange. Mixins will get
> the newly generated id passed in to their initialize(), where you would then
> attach an onchange listener with prototype observe.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: How to fix the id attribute of a select component
Posted by LLTYK <LL...@mailinator.com>.
The current "solution" is to use a mixin instead of onchange. Mixins will get
the newly generated id passed in to their initialize(), where you would then
attach an onchange listener with prototype observe.
--
View this message in context: http://tapestry-users.832.n2.nabble.com/How-to-fix-the-id-attribute-of-a-select-component-tp5999701p6004558.html
Sent from the Tapestry Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: How to fix the id attribute of a select component
Posted by Richard Hill <ri...@su3analytics.com>.
Well apparently there is this clientid attribute you can add to the
component in .tml which I understand from Igor is supposed to allow you
to do just this. However it didn't work for me :(
On Tue, 2011-02-08 at 10:52 -0500, Benny Law wrote:
> Yes, but in this case, I don't see any potential for conflicts. After
> the zone update, you will still have one select element, but with a
> new id. This seems to have tripped up people who are new to Tapestry.
>
> My question is, does it not make sense to perhaps add a parameter to
> the zone component so that the developer can basically say, "I know
> what I am doing, and I don't want the ids to be updated please",
> something like <t:zone ... updateIds="false" ...>? I know we can work
> around this by using CSS classes instead of ids to reference the
> elements, but it's just not the natural thing to do.
>
> Benny
>
> On Tue, Feb 8, 2011 at 10:36 AM, Richard Hill <ri...@su3analytics.com>
> wrote:
>
> Sure. But in my case I have only the one element, it's static
> in .tml
> and not rendered in a loop.
>
> I think maybe what's causing it is that the element (t:select)
> is
> contained within the zone it updates.
>
>
>
> On Tue, 2011-02-08 at 12:56 -0200, Thiago H. de Paula
> Figueiredo wrote:
> > On Tue, 08 Feb 2011 12:50:57 -0200, Benny Law
> <be...@gmail.com>
> > wrote:
> >
> > > I understand that Tapestry is doing this to avoid
> potential conflicts,
> > > but can somebody provide a real example of when this is
> necessary?
> >
> > Anytime you could have the same id used twice in a page,
> something that is
> > forbidden by HTML and causes lots of confusion in JavaScript
> and CSS. This
> > can happen in at least two situations: loops and AJAX
> updates.
> >
>
>
>
>
>
> ---------------------------------------------------------------------
> 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: How to fix the id attribute of a select component
Posted by Benny Law <be...@gmail.com>.
Yes, but in this case, I don't see any potential for conflicts. After the
zone update, you will still have one select element, but with a new id. This
seems to have tripped up people who are new to Tapestry.
My question is, does it not make sense to perhaps add a parameter to the
zone component so that the developer can basically say, "I know what I am
doing, and I don't want the ids to be updated please", something like
<t:zone ... updateIds="false" ...>? I know we can work around this by using
CSS classes instead of ids to reference the elements, but it's just not the
natural thing to do.
Benny
On Tue, Feb 8, 2011 at 10:36 AM, Richard Hill <ri...@su3analytics.com> wrote:
>
> Sure. But in my case I have only the one element, it's static in .tml
> and not rendered in a loop.
>
> I think maybe what's causing it is that the element (t:select) is
> contained within the zone it updates.
>
>
>
> On Tue, 2011-02-08 at 12:56 -0200, Thiago H. de Paula Figueiredo wrote:
> > On Tue, 08 Feb 2011 12:50:57 -0200, Benny Law <be...@gmail.com>
> > wrote:
> >
> > > I understand that Tapestry is doing this to avoid potential conflicts,
> > > but can somebody provide a real example of when this is necessary?
> >
> > Anytime you could have the same id used twice in a page, something that
> is
> > forbidden by HTML and causes lots of confusion in JavaScript and CSS.
> This
> > can happen in at least two situations: loops and AJAX updates.
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: How to fix the id attribute of a select component
Posted by Richard Hill <ri...@su3analytics.com>.
Sure. But in my case I have only the one element, it's static in .tml
and not rendered in a loop.
I think maybe what's causing it is that the element (t:select) is
contained within the zone it updates.
On Tue, 2011-02-08 at 12:56 -0200, Thiago H. de Paula Figueiredo wrote:
> On Tue, 08 Feb 2011 12:50:57 -0200, Benny Law <be...@gmail.com>
> wrote:
>
> > I understand that Tapestry is doing this to avoid potential conflicts,
> > but can somebody provide a real example of when this is necessary?
>
> Anytime you could have the same id used twice in a page, something that is
> forbidden by HTML and causes lots of confusion in JavaScript and CSS. This
> can happen in at least two situations: loops and AJAX updates.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: How to fix the id attribute of a select component
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 08 Feb 2011 12:50:57 -0200, Benny Law <be...@gmail.com>
wrote:
> I understand that Tapestry is doing this to avoid potential conflicts,
> but can somebody provide a real example of when this is necessary?
Anytime you could have the same id used twice in a page, something that is
forbidden by HTML and causes lots of confusion in JavaScript and CSS. This
can happen in at least two situations: loops and AJAX updates.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: How to fix the id attribute of a select component
Posted by Benny Law <be...@gmail.com>.
I understand that Tapestry is doing this to avoid potential conflicts, but
can somebody provide a real example of when this is necessary? This behavior
seems to be causing confusion and inconvenience to people, myself included.
Even when the danger of the conflict is real, there are still cases when it
is not, so perphaps making this behavior an option and allowing the
developer control over it will make life easier for some.
Benny
On Tue, Feb 8, 2011 at 9:28 AM, Richard Hill <ri...@su3analytics.com> wrote:
>
> Hi Mark,
>
> Yes that is correct, it is being clobbered by tapestry (5.2) -
> specifically tapestry is appending a character sequence like
> "myIdName_672hjfty6". I have also tried Igor's suggestion of "clientId"
> and various permutations, but no luck I'm afraid.
>
> R.
>
>
>
> On Mon, 2011-02-07 at 11:40 -0600, Mark wrote:
>
> > So when you use:
> >
> > <t:select t:type="select"
> > t:id="cctEditSelect"
> > t:blankOption="NEVER"
> > onchange="_SU3.renderWebOptions();"
> > id="myIdName"/>
> >
> > myIdName is being overwritten by something else?
> >
> > Mark
> >
> > On Mon, Feb 7, 2011 at 5:23 AM, Richard Hill <ri...@su3analytics.com>
> wrote:
> > >
> > > Hi Igor,
> > >
> > > Thanks for the response. I forget to mention in my original email that
> I
> > > tried setting the id attribute as well, but to no avail - it gets
> > > over-written. This is T5.2.
> > >
> > > Richard.
> > >
> > >
> > >
> > >
> > > On Mon, 2011-02-07 at 12:20 +0100, Igor Drobiazko wrote:
> > >> t:id is a Tapestry component id, which has nothing to do with the
> > >> client-side id of the tag written by the component. You should use the
> > >> clientId parameter.
> > >>
> > >> On Mon, Feb 7, 2011 at 10:30 AM, Richard Hill <ri...@su3analytics.com>
> > >> wrote:
> > >>
> > >> Hi All,
> > >>
> > >> I have a select component in a block:
> > >>
> > >> <t:select t:type="select" t:id="cctEditSelect"
> > >> t:blankOption="NEVER"
> > >> onchange="_SU3.renderWebOptions();"/>
> > >>
> > >> The block is the second of three. The switching between them
> > >> is
> > >> accomplished with an ajax actionlink request and a <t:delegate
> > >> to />
> > >>
> > >> By default the first block is shown on page load. If I then
> > >> switch to
> > >> the second block, the id attribute of the <t:select> is
> > >> something like:
> > >>
> > >> id="cctEditSelect_947gyh0"
> > >>
> > >> My onchange javascript function expects this to be simply
> > >> "cctEditSelect". If I refresh the whole page, then the id _is_
> > >> rendered
> > >> just "cctEditSelect" (the currently visible block is
> > >> @Persist'd). It's
> > >> only when switching from another block do I get the random
> > >> characters
> > >> appended.
> > >>
> > >> I'm guessing this is to do with Tapestry making sure there are
> > >> no id
> > >> conflicts. I have tried to force the id, by putting in
> > >> my .java:
> > >>
> > >> @InjectComponent
> > >> @Id("cctEditSelect")
> > >> private Select cctEditSelect;
> > >>
> > >> But no juice - I get the same behaviour. How can I fix this id
> > >> attribute?
> > >>
> > >> Many thanks,
> > >>
> > >> Richard.
> > >>
> > >>
> > >>
> > >>
> > >>
> > >>
> > >> --
> > >> Best regards,
> > >>
> > >> Igor Drobiazko
> > >> http://tapestry5.de
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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: How to fix the id attribute of a select component
Posted by Richard Hill <ri...@su3analytics.com>.
Hi Mark,
Yes that is correct, it is being clobbered by tapestry (5.2) -
specifically tapestry is appending a character sequence like
"myIdName_672hjfty6". I have also tried Igor's suggestion of "clientId"
and various permutations, but no luck I'm afraid.
R.
On Mon, 2011-02-07 at 11:40 -0600, Mark wrote:
> So when you use:
>
> <t:select t:type="select"
> t:id="cctEditSelect"
> t:blankOption="NEVER"
> onchange="_SU3.renderWebOptions();"
> id="myIdName"/>
>
> myIdName is being overwritten by something else?
>
> Mark
>
> On Mon, Feb 7, 2011 at 5:23 AM, Richard Hill <ri...@su3analytics.com> wrote:
> >
> > Hi Igor,
> >
> > Thanks for the response. I forget to mention in my original email that I
> > tried setting the id attribute as well, but to no avail - it gets
> > over-written. This is T5.2.
> >
> > Richard.
> >
> >
> >
> >
> > On Mon, 2011-02-07 at 12:20 +0100, Igor Drobiazko wrote:
> >> t:id is a Tapestry component id, which has nothing to do with the
> >> client-side id of the tag written by the component. You should use the
> >> clientId parameter.
> >>
> >> On Mon, Feb 7, 2011 at 10:30 AM, Richard Hill <ri...@su3analytics.com>
> >> wrote:
> >>
> >> Hi All,
> >>
> >> I have a select component in a block:
> >>
> >> <t:select t:type="select" t:id="cctEditSelect"
> >> t:blankOption="NEVER"
> >> onchange="_SU3.renderWebOptions();"/>
> >>
> >> The block is the second of three. The switching between them
> >> is
> >> accomplished with an ajax actionlink request and a <t:delegate
> >> to />
> >>
> >> By default the first block is shown on page load. If I then
> >> switch to
> >> the second block, the id attribute of the <t:select> is
> >> something like:
> >>
> >> id="cctEditSelect_947gyh0"
> >>
> >> My onchange javascript function expects this to be simply
> >> "cctEditSelect". If I refresh the whole page, then the id _is_
> >> rendered
> >> just "cctEditSelect" (the currently visible block is
> >> @Persist'd). It's
> >> only when switching from another block do I get the random
> >> characters
> >> appended.
> >>
> >> I'm guessing this is to do with Tapestry making sure there are
> >> no id
> >> conflicts. I have tried to force the id, by putting in
> >> my .java:
> >>
> >> @InjectComponent
> >> @Id("cctEditSelect")
> >> private Select cctEditSelect;
> >>
> >> But no juice - I get the same behaviour. How can I fix this id
> >> attribute?
> >>
> >> Many thanks,
> >>
> >> Richard.
> >>
> >>
> >>
> >>
> >>
> >>
> >> --
> >> Best regards,
> >>
> >> Igor Drobiazko
> >> http://tapestry5.de
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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: How to fix the id attribute of a select component
Posted by LLTYK <LL...@mailinator.com>.
When you load Tapestry components in an ajax request a new t:id is generated.
Presumably because it's possible for a component with the same original id
to still be on the page. I'm not sure how this relates to the client side
id.
--
View this message in context: http://tapestry-users.832.n2.nabble.com/How-to-fix-the-id-attribute-of-a-select-component-tp5999701p6001123.html
Sent from the Tapestry Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: How to fix the id attribute of a select component
Posted by Mark <ma...@xeric.net>.
So when you use:
<t:select t:type="select"
t:id="cctEditSelect"
t:blankOption="NEVER"
onchange="_SU3.renderWebOptions();"
id="myIdName"/>
myIdName is being overwritten by something else?
Mark
On Mon, Feb 7, 2011 at 5:23 AM, Richard Hill <ri...@su3analytics.com> wrote:
>
> Hi Igor,
>
> Thanks for the response. I forget to mention in my original email that I
> tried setting the id attribute as well, but to no avail - it gets
> over-written. This is T5.2.
>
> Richard.
>
>
>
>
> On Mon, 2011-02-07 at 12:20 +0100, Igor Drobiazko wrote:
>> t:id is a Tapestry component id, which has nothing to do with the
>> client-side id of the tag written by the component. You should use the
>> clientId parameter.
>>
>> On Mon, Feb 7, 2011 at 10:30 AM, Richard Hill <ri...@su3analytics.com>
>> wrote:
>>
>> Hi All,
>>
>> I have a select component in a block:
>>
>> <t:select t:type="select" t:id="cctEditSelect"
>> t:blankOption="NEVER"
>> onchange="_SU3.renderWebOptions();"/>
>>
>> The block is the second of three. The switching between them
>> is
>> accomplished with an ajax actionlink request and a <t:delegate
>> to />
>>
>> By default the first block is shown on page load. If I then
>> switch to
>> the second block, the id attribute of the <t:select> is
>> something like:
>>
>> id="cctEditSelect_947gyh0"
>>
>> My onchange javascript function expects this to be simply
>> "cctEditSelect". If I refresh the whole page, then the id _is_
>> rendered
>> just "cctEditSelect" (the currently visible block is
>> @Persist'd). It's
>> only when switching from another block do I get the random
>> characters
>> appended.
>>
>> I'm guessing this is to do with Tapestry making sure there are
>> no id
>> conflicts. I have tried to force the id, by putting in
>> my .java:
>>
>> @InjectComponent
>> @Id("cctEditSelect")
>> private Select cctEditSelect;
>>
>> But no juice - I get the same behaviour. How can I fix this id
>> attribute?
>>
>> Many thanks,
>>
>> Richard.
>>
>>
>>
>>
>>
>>
>> --
>> Best regards,
>>
>> Igor Drobiazko
>> http://tapestry5.de
>
>
>
> ---------------------------------------------------------------------
> 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: How to fix the id attribute of a select component
Posted by Richard Hill <ri...@su3analytics.com>.
Hi Igor,
Thanks for the response. I forget to mention in my original email that I
tried setting the id attribute as well, but to no avail - it gets
over-written. This is T5.2.
Richard.
On Mon, 2011-02-07 at 12:20 +0100, Igor Drobiazko wrote:
> t:id is a Tapestry component id, which has nothing to do with the
> client-side id of the tag written by the component. You should use the
> clientId parameter.
>
> On Mon, Feb 7, 2011 at 10:30 AM, Richard Hill <ri...@su3analytics.com>
> wrote:
>
> Hi All,
>
> I have a select component in a block:
>
> <t:select t:type="select" t:id="cctEditSelect"
> t:blankOption="NEVER"
> onchange="_SU3.renderWebOptions();"/>
>
> The block is the second of three. The switching between them
> is
> accomplished with an ajax actionlink request and a <t:delegate
> to />
>
> By default the first block is shown on page load. If I then
> switch to
> the second block, the id attribute of the <t:select> is
> something like:
>
> id="cctEditSelect_947gyh0"
>
> My onchange javascript function expects this to be simply
> "cctEditSelect". If I refresh the whole page, then the id _is_
> rendered
> just "cctEditSelect" (the currently visible block is
> @Persist'd). It's
> only when switching from another block do I get the random
> characters
> appended.
>
> I'm guessing this is to do with Tapestry making sure there are
> no id
> conflicts. I have tried to force the id, by putting in
> my .java:
>
> @InjectComponent
> @Id("cctEditSelect")
> private Select cctEditSelect;
>
> But no juice - I get the same behaviour. How can I fix this id
> attribute?
>
> Many thanks,
>
> Richard.
>
>
>
>
>
>
> --
> Best regards,
>
> Igor Drobiazko
> http://tapestry5.de
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: How to fix the id attribute of a select component
Posted by Igor Drobiazko <ig...@gmail.com>.
t:id is a Tapestry component id, which has nothing to do with the
client-side id of the tag written by the component. You should use the
clientId parameter.
On Mon, Feb 7, 2011 at 10:30 AM, Richard Hill <ri...@su3analytics.com> wrote:
>
> Hi All,
>
> I have a select component in a block:
>
> <t:select t:type="select" t:id="cctEditSelect" t:blankOption="NEVER"
> onchange="_SU3.renderWebOptions();"/>
>
> The block is the second of three. The switching between them is
> accomplished with an ajax actionlink request and a <t:delegate to />
>
> By default the first block is shown on page load. If I then switch to
> the second block, the id attribute of the <t:select> is something like:
>
> id="cctEditSelect_947gyh0"
>
> My onchange javascript function expects this to be simply
> "cctEditSelect". If I refresh the whole page, then the id _is_ rendered
> just "cctEditSelect" (the currently visible block is @Persist'd). It's
> only when switching from another block do I get the random characters
> appended.
>
> I'm guessing this is to do with Tapestry making sure there are no id
> conflicts. I have tried to force the id, by putting in my .java:
>
> @InjectComponent
> @Id("cctEditSelect")
> private Select cctEditSelect;
>
> But no juice - I get the same behaviour. How can I fix this id
> attribute?
>
> Many thanks,
>
> Richard.
>
>
>
>
--
Best regards,
Igor Drobiazko
http://tapestry5.de