tapestry-user@jakarta.apache.org
[Top] [All Lists]

Re: Best Practice: Controlling Page Names

Subject: Re: Best Practice: Controlling Page Names
From: "Adam Zimowski"
Date: Mon, 6 Mar 2006 11:11:32 -0600
Thanks much, Till.   I'm on JDK 1.5 and tried
MyPage.class.getSimpleName() but compiler is smart enough to figure
out this is a non constant expression and won't let you inject page:

@InjectPage(MyPage.class.getSimpleName())

:-(

On 3/6/06, Till Nagel <tn@xxxxxxx> wrote:
> Adam,
>
> to avoid repeating the page name as string constant, you could use
>
> public static final String NAME =
> MyPage.class.getName().replaceAll(".*\\.", "");
>
> or, if you are using Java 1.5
>
> public static final String NAME = MyPage.class.getSimpleName();
>
>
>
> > -----Original Message-----
> > From: Adam Zimowski [mailto:zimowski74@xxxxxxxxx]
> > Sent: Friday, March 03, 2006 9:04 PM
> > To: Tapestry users
> > Subject: Re: Best Practice: Controlling Page Names
> >
> > Enums wouldn't work because .toString() would result in a non-constant
> > expression.
> >
> > So let's assume every page has:
> >
> > public static final String NAME = "page_name as defined in
> *.application
> > file";
> >
> > Then:
> >
> > @InjectPage(Page.NAME)
> >
> > Is this a clean way to do this?
> >
> > On 3/3/06, Adam Zimowski <zimowski74@xxxxxxxxx> wrote:
> > > I'd like to hear what you folks would recommend for controlling when
> > > referring to pages via their names, such as:
> > >
> > > @InjectPage("Registration")
> > >
> > > etc..
> > >
> > > If I have the same page injected in 20 places, then rename the page
> it
> > > would be a pain to refactor. Since I'm on JDK 1.5, I'm thinking of
> > > creating page enum, and since toString() of an enum is its value it
> > > would work rather nicely:
> > >
> > > public enum EPages { Home, Registration, etc... }
> > >
> > > @InjectPage(EPages.Registration)
> > >
> > > Sure, I have one more place to maintain with page names, but I
> > > wouldn't mind it comparing to current state of affairs.
> > >
> > > Or is there even a better way?  I'd like to keep injection
> annotation
> > > because I've come so accustomed to it.
> > >
> > > Regards,
> > > Adam
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@xxxxxxxxxxxxxxxxxx
> > For additional commands, e-mail: tapestry-user-help@xxxxxxxxxxxxxxxxxx
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@xxxxxxxxxxxxxxxxxx
> For additional commands, e-mail: tapestry-user-help@xxxxxxxxxxxxxxxxxx
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: tapestry-user-help@xxxxxxxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>