You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michael Gerzabek <mi...@gmx.net> on 2007/10/13 13:08:43 UTC
[T5] Label
Hi,
Another question from a newbie. What would it take to read the text
surrounded by <t:label for="someAttribute">A pretty label
text:</t:label> and use this if no .properties are provided?
Michael
--
"Path is created through walking" [winged words]
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [T5] Label
Posted by Michael Gerzabek <mi...@gmx.net>.
Hi Nick,
That was REALLY easy! Wow, 5 minutes and a new component is born. It's
hard to believe. The more I work with T5 the more I like it.
So let's have a look at RadioGroup...
Cheers,
Michael
Nick Westgate schrieb:
> Hi Michael.
>
> In the future it should be easy to do this with a Mixin, but there are
> a couple of problems that might (or might not) get in the way currently.
>
> Anyway, it's very easy to write components. Just take the Radio.java
> source eg from http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/
> tapestry-core/src/main/java/org/apache/tapestry/corelib/components
>
> and hack away till it does what you want. In this case, change:
> @BeforeRenderBody
> boolean renderBody()
> {
> // Don't render the body of the component even if there is one.
>
> return false;
> }
>
> to return true based on the criteria you want, and the opposite here:
> @AfterRender
> void after(MarkupWriter writer)
> {
> writer.write(_field.getLabel());
>
> writer.end(); // label
> }
>
> To see how to write your own components and where to put things see:
> http://wiki.apache.org/tapestry/Tapestry5HowTos
>
> Note that if you are using T5.0.6 then a few things have changed like
> templates are now named *.tml. Search the list for other changes.
>
> Cheers,
> Nick.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [T5] Label
Posted by Nick Westgate <ni...@key-planning.co.jp>.
Hi Michael.
In the future it should be easy to do this with a Mixin, but there are
a couple of problems that might (or might not) get in the way currently.
Anyway, it's very easy to write components. Just take the Radio.java
source eg from http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/
tapestry-core/src/main/java/org/apache/tapestry/corelib/components
and hack away till it does what you want. In this case, change:
@BeforeRenderBody
boolean renderBody()
{
// Don't render the body of the component even if there is one.
return false;
}
to return true based on the criteria you want, and the opposite here:
@AfterRender
void after(MarkupWriter writer)
{
writer.write(_field.getLabel());
writer.end(); // label
}
To see how to write your own components and where to put things see:
http://wiki.apache.org/tapestry/Tapestry5HowTos
Note that if you are using T5.0.6 then a few things have changed like
templates are now named *.tml. Search the list for other changes.
Cheers,
Nick.
Michael Gerzabek wrote:
> Hi,
>
> Another question from a newbie. What would it take to read the text
> surrounded by <t:label for="someAttribute">A pretty label
> text:</t:label> and use this if no .properties are provided?
>
> Michael
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org