You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Daniel Jue <te...@gmail.com> on 2007/10/09 16:46:21 UTC

T5 If component and static variables

Hi, I wanted to try eliminating a bunch of getters in my Java class.

Right now I have something like this in my template:

<t:if test="showYear">
	<t:selectyear />
</t:if>

And I have a getter that is

public boolean getShowYear() {
	return this.getUsesSetting(ReportVariableEnum.FISCALYEARSINGLE);
}


I want to do something like this:

<t:if test="getUsesSetting(ReportVariableEnum.PARTICULARVARIABLE)">
     This uses Particular Variable
</t:if>

So I will only have to have getUsesSetting() in my page class.

I have about 30 or so components, with 30 or so getters, and with 30
or so getShowComponentName() methods.

This class is getting to be a pain to read through.

Any Ideas?

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


Re: T5 If component and static variables

Posted by Daniel Jue <te...@gmail.com>.
I knew this felt familiar; the issue came up a couple months ago, but
with no solution at the time.  This isn't a really a problem, it's a
matter of convenience for programmers.

The thread was:
"T5: static page variables in templates"

On 10/9/07, Daniel Jue <te...@gmail.com> wrote:
> Hi, I wanted to try eliminating a bunch of getters in my Java class.
>
> Right now I have something like this in my template:
>
> <t:if test="showYear">
>         <t:selectyear />
> </t:if>
>
> And I have a getter that is
>
> public boolean getShowYear() {
>         return this.getUsesSetting(ReportVariableEnum.FISCALYEARSINGLE);
> }
>
>
> I want to do something like this:
>
> <t:if test="getUsesSetting(ReportVariableEnum.PARTICULARVARIABLE)">
>      This uses Particular Variable
> </t:if>
>
> So I will only have to have getUsesSetting() in my page class.
>
> I have about 30 or so components, with 30 or so getters, and with 30
> or so getShowComponentName() methods.
>
> This class is getting to be a pain to read through.
>
> Any Ideas?
>

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


Re: T5 If component and static variables

Posted by Howard Lewis Ship <hl...@gmail.com>.
There's a couple of options here.

One is to use a common base class that defines all of these getters.

Create your own component that acts like an If but the tests is hard
coded against the
getUsesSetting() logic.

Another option is to create a new binding prefix, i.e.,

<t:if test="uses:fiscale_yearsingle">

Where the uses: prefix would be something you can (relatively easily)
implement.  There are some decent notes on the wiki for this.

I would strongly explore the latter possibility.  To me, this is a
very exciting avenue in Tapestry 5 (present also in T4, but just
easier in T5) that components can be reused not just by aggregation
and inheritance, but also with a kind of dramatic reinterpretation of
what their parameters mean.

On 10/9/07, Daniel Jue <te...@gmail.com> wrote:
> Hi, I wanted to try eliminating a bunch of getters in my Java class.
>
> Right now I have something like this in my template:
>
> <t:if test="showYear">
>         <t:selectyear />
> </t:if>
>
> And I have a getter that is
>
> public boolean getShowYear() {
>         return this.getUsesSetting(ReportVariableEnum.FISCALYEARSINGLE);
> }
>
>
> I want to do something like this:
>
> <t:if test="getUsesSetting(ReportVariableEnum.PARTICULARVARIABLE)">
>      This uses Particular Variable
> </t:if>
>
> So I will only have to have getUsesSetting() in my page class.
>
> I have about 30 or so components, with 30 or so getters, and with 30
> or so getShowComponentName() methods.
>
> This class is getting to be a pain to read through.
>
> Any Ideas?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
Partner and Senior Architect at Feature50

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