You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Luther Baker <lu...@gmail.com> on 2008/09/14 17:32:22 UTC

id parameter

I'm writing a custom component - basically wrapping an html fieldset with my
own logic.

I would like to echo the id supplied to the component. This works just fine:



<t:fieldSet id="todo" legend="Todo">...</t:fieldSet>


with this backing class:


public class FieldSet
{
    @Property
    @Parameter(required=true, defaultPrefix="literal")
    private String id;

    @Property
    @Parameter(required=true, defaultPrefix="literal")
    private String legend;
}


My question is: do I gain anything from this change:


<t:fieldSet *t:id="todo"* legend="Todo">


I know that with built-in components, the id field has a special meaning
such that you must qualify it like *t:id* ... for example <t:textfield
t:id="userId"/>. What does that do? What does that mean for "userId"? Is it
specific to this control or is this a general pattern? Does using
*t:id*facilitate something else?

I'm looking on the
http://tapestry.apache.org/tapestry5/guide/parameters.html parameters page
... but not sure I see much about this. So - give it a go and unfortunately,
this doesn't just magically work: <t:fieldSet *t:id="todo"* legend="Todo">.
I get an exception: I am missing whatever I need to do to grab this id and
use it in my FieldSet *.tml file:

Firstly, I get this:

Parameter(s) 'id' are required for
com.effectiveprogramming.notebook.components.FieldSet, but have not been
bound.

So I remove that field and annotation from the Java class. Then it rightly
complains about the *.tml trying to write the ${id} out


<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
    <fieldset id="${id}">
        <legend>${legend}</legend>
        <t:body/>
    </fieldset>
</t:container>


with: Could not convert 'id' into a component parameter binding: Class
com.effectiveprogramming.notebook.components.FieldSet does not contain a
property named 'id' (within property expression 'id'). Available properties:
class, componentResources, legend.

So, the *.tml wants to display the ${id} - but per my recent change to the
JAVA file, t:id from the enclosing page doesn't map to this id parameter.
So, maybe there is some other way my JAVA class can save the t:id field and
some other way that that *.tml file can render the ${id} field?

Any suggestions would be much appreciated. Maybe I should just use the
simple straightforward setting - but it seems like t:id has some special
meaning that I need to understand. What does the t:id do and how do I
utilize that?

Thanks so much for any suggestions,

-Luther

Re: id parameter

Posted by Luther Baker <lu...@gmail.com>.
I found a little more info for this here:
http://tapestry.apache.org/tapestry5/tapestry-core/guide/templates.html.

I see that

*id: A unique id for the component (within its container)
*
What I don't see is how I have access to this t:id from within  my custom
component. Or ... is this t:id really just for the underlying Tapestry
infrastructure and I really shouldn't be using it.

I'd like to pass that id on to the html ... but must I simply use another
parameter for that?

Thank much,

-Luther




On Sun, Sep 14, 2008 at 10:32 AM, Luther Baker <lu...@gmail.com>wrote:

> I'm writing a custom component - basically wrapping an html fieldset with
> my own logic.
>
> I would like to echo the id supplied to the component. This works just
> fine:
>
>
> <t:fieldSet id="todo" legend="Todo">...</t:fieldSet>
>
>
> with this backing class:
>
>
> public class FieldSet
> {
>     @Property
>     @Parameter(required=true, defaultPrefix="literal")
>     private String id;
>
>     @Property
>     @Parameter(required=true, defaultPrefix="literal")
>     private String legend;
> }
>
>
> My question is: do I gain anything from this change:
>
>
> <t:fieldSet *t:id="todo"* legend="Todo">
>
>
> I know that with built-in components, the id field has a special meaning
> such that you must qualify it like *t:id* ... for example <t:textfield
> t:id="userId"/>. What does that do? What does that mean for "userId"? Is it
> specific to this control or is this a general pattern? Does using *t:id*facilitate something else?
>
> I'm looking on the
> http://tapestry.apache.org/tapestry5/guide/parameters.html parameters page
> ... but not sure I see much about this. So - give it a go and unfortunately,
> this doesn't just magically work: <t:fieldSet *t:id="todo"*legend="Todo">. I get an exception: I am missing whatever I need to do to
> grab this id and use it in my FieldSet *.tml file:
>
> Firstly, I get this:
>
> Parameter(s) 'id' are required for
> com.effectiveprogramming.notebook.components.FieldSet, but have not been
> bound.
>
> So I remove that field and annotation from the Java class. Then it rightly
> complains about the *.tml trying to write the ${id} out
>
>
> <t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd
> ">
>     <fieldset id="${id}">
>         <legend>${legend}</legend>
>         <t:body/>
>     </fieldset>
> </t:container>
>
>
> with: Could not convert 'id' into a component parameter binding: Class
> com.effectiveprogramming.notebook.components.FieldSet does not contain a
> property named 'id' (within property expression 'id'). Available properties:
> class, componentResources, legend.
>
> So, the *.tml wants to display the ${id} - but per my recent change to the
> JAVA file, t:id from the enclosing page doesn't map to this id parameter.
> So, maybe there is some other way my JAVA class can save the t:id field and
> some other way that that *.tml file can render the ${id} field?
>
> Any suggestions would be much appreciated. Maybe I should just use the
> simple straightforward setting - but it seems like t:id has some special
> meaning that I need to understand. What does the t:id do and how do I
> utilize that?
>
> Thanks so much for any suggestions,
>
> -Luther
>
>
>
>
>