You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by John <jo...@quivinco.com> on 2013/04/28 11:27:57 UTC

Tepestry equivalent of a jsp:useBean?

I'd like to be able to assign a bean to page scope so that the property getter is not repeatedly invoked. I'm guessing this might not be compatible with Tapestry practice, but anyway.

I suppose I could assign a member as a persistent property and then switch it as required, but I'd like to do something more like this:

<t:useBean id="bean" t:source="prop:beanGetter"/>

    ${bean.total}

    ${bean.messages}

Sometimes I prefer to provide properties with a get method that I don't want repeatedly invoked because of the cost.

John

Re: Tepestry equivalent of a jsp:useBean?

Posted by John <jo...@quivinco.com>.
Hi,

Thanks, yes I've used both these approaches. Assigning a page property is the neater one IMO.

The Tapestry ways are better than defining stuff in the template and creating clutter.

John
  ----- Original Message ----- 
  From: Chris Poulsen 
  To: Tapestry users 
  Sent: Sunday, April 28, 2013 10:43 AM
  Subject: Re: Tepestry equivalent of a jsp:useBean?


  Hi,

  You could get/set the bean instance in a page field before rendering the
  page. Then you would only perform the expensive get once.

  Or you could use @Cached for the bean getter.

  --

  Chris


  On Sun, Apr 28, 2013 at 11:27 AM, John <jo...@quivinco.com> wrote:

  > I'd like to be able to assign a bean to page scope so that the property
  > getter is not repeatedly invoked. I'm guessing this might not be compatible
  > with Tapestry practice, but anyway.
  >
  > I suppose I could assign a member as a persistent property and then switch
  > it as required, but I'd like to do something more like this:
  >
  > <t:useBean id="bean" t:source="prop:beanGetter"/>
  >
  >     ${bean.total}
  >
  >     ${bean.messages}
  >
  > Sometimes I prefer to provide properties with a get method that I don't
  > want repeatedly invoked because of the cost.
  >
  > John

Re: Tepestry equivalent of a jsp:useBean?

Posted by Lance Java <la...@googlemail.com>.
You might find this page useful
http://tapestry.apache.org/tapestry-for-jsf-users.html


On 28 April 2013 10:43, Chris Poulsen <ma...@nesluop.dk> wrote:

> Hi,
>
> You could get/set the bean instance in a page field before rendering the
> page. Then you would only perform the expensive get once.
>
> Or you could use @Cached for the bean getter.
>
> --
>
> Chris
>
>
> On Sun, Apr 28, 2013 at 11:27 AM, John <jo...@quivinco.com> wrote:
>
> > I'd like to be able to assign a bean to page scope so that the property
> > getter is not repeatedly invoked. I'm guessing this might not be
> compatible
> > with Tapestry practice, but anyway.
> >
> > I suppose I could assign a member as a persistent property and then
> switch
> > it as required, but I'd like to do something more like this:
> >
> > <t:useBean id="bean" t:source="prop:beanGetter"/>
> >
> >     ${bean.total}
> >
> >     ${bean.messages}
> >
> > Sometimes I prefer to provide properties with a get method that I don't
> > want repeatedly invoked because of the cost.
> >
> > John
>

Re: Tepestry equivalent of a jsp:useBean?

Posted by Chris Poulsen <ma...@nesluop.dk>.
Hi,

You could get/set the bean instance in a page field before rendering the
page. Then you would only perform the expensive get once.

Or you could use @Cached for the bean getter.

--

Chris


On Sun, Apr 28, 2013 at 11:27 AM, John <jo...@quivinco.com> wrote:

> I'd like to be able to assign a bean to page scope so that the property
> getter is not repeatedly invoked. I'm guessing this might not be compatible
> with Tapestry practice, but anyway.
>
> I suppose I could assign a member as a persistent property and then switch
> it as required, but I'd like to do something more like this:
>
> <t:useBean id="bean" t:source="prop:beanGetter"/>
>
>     ${bean.total}
>
>     ${bean.messages}
>
> Sometimes I prefer to provide properties with a get method that I don't
> want repeatedly invoked because of the cost.
>
> John