You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Stephane Decleire <sd...@cariboo-networks.com> on 2009/02/16 16:08:41 UTC

T5 : naming of subcomponents ...

Hi all,

I would like to have your opinion on the following case :

I want to create a Tapestry component as an assembly of several
components and javascript functions (in a .js file) and those functions
need to have access to the components' values.
This component could be, for example a "birthdate" component with say 2
selection boxes for the day and the month and a textfied for the year.
The javascript functions could check the values of the different fields
before they are sent to the server part of the application.

So my question is "How can i name my select and textfield components to
access them from the javascript functions ?"
1. If i let Tapestry build a default id for my subcomponents, i won't
know their ids to use them in my javascript functions.
2. If i give myself "hardcoded" names for my subcomponents and package
my birthdate component in a library, they may be a clash beetween those
names and ones already used on a page in a specific application.
3. I have thought about prefixing my subcomponents ids with the
component id like ${componentid}:day, ${componentid}:month,
${componentid}:year (this implementation seems to be used in the palette
component ...). By passing the id of my component as a parameter of my
javascript initialization function, i could get access to my
subcomponents in my javascript functions. And, as the id of my component
is unique, the ids of my subcomponents will also be unique. But Tapestry
doesn't let me build "composite" ids : i can't use ${componentid}:day as
an id in a tml file and the getClientId() of the AbstractField class
can't be overriden if i want to create "evolutions" of the Tapestry
components which could take a prefix for their id as a parameter ...


Did i miss something ? Is there another way to build Tapestry
"composite" components ?
Thanks in advance for any advice.

Stephane


Re: T5 : naming of subcomponents ...

Posted by Howard Lewis Ship <hl...@gmail.com>.
Build the JavaScript around the actual ids that Tapestry generates:
use @InjectComponent on the sub-components, and invoke getClientId().
Then build dynamic JavaScript that ties it all together on the client
side from the ids.  i.e.

renderSupport.addInit("new BirthdayController('%s', '%s', '%s');",
monthField.getClientId(), dayField.getClientId(),
yearField.getClientId());

On Mon, Feb 16, 2009 at 7:08 AM, Stephane Decleire
<sd...@cariboo-networks.com> wrote:
> Hi all,
>
> I would like to have your opinion on the following case :
>
> I want to create a Tapestry component as an assembly of several
> components and javascript functions (in a .js file) and those functions
> need to have access to the components' values.
> This component could be, for example a "birthdate" component with say 2
> selection boxes for the day and the month and a textfied for the year.
> The javascript functions could check the values of the different fields
> before they are sent to the server part of the application.
>
> So my question is "How can i name my select and textfield components to
> access them from the javascript functions ?"
> 1. If i let Tapestry build a default id for my subcomponents, i won't
> know their ids to use them in my javascript functions.
> 2. If i give myself "hardcoded" names for my subcomponents and package
> my birthdate component in a library, they may be a clash beetween those
> names and ones already used on a page in a specific application.
> 3. I have thought about prefixing my subcomponents ids with the
> component id like ${componentid}:day, ${componentid}:month,
> ${componentid}:year (this implementation seems to be used in the palette
> component ...). By passing the id of my component as a parameter of my
> javascript initialization function, i could get access to my
> subcomponents in my javascript functions. And, as the id of my component
> is unique, the ids of my subcomponents will also be unique. But Tapestry
> doesn't let me build "composite" ids : i can't use ${componentid}:day as
> an id in a tml file and the getClientId() of the AbstractField class
> can't be overriden if i want to create "evolutions" of the Tapestry
> components which could take a prefix for their id as a parameter ...
>
>
> Did i miss something ? Is there another way to build Tapestry
> "composite" components ?
> Thanks in advance for any advice.
>
> Stephane
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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