You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Karthik N <ka...@gmail.com> on 2007/04/16 14:05:51 UTC

tapestry 4.0.2: How do I get a new page object?

Hi,

While I am in a page "Page1" listener method and  when I execute the
following code:

		newPage = currentPage.getRequestCycle().getPage("Page1" );

I find that newPage and this page are both the same object

i.e. System.out.println( newPage == this ); evals to true

I have a requirement however where I want newPage to be a different
instance than this

Any ideas how this can be achieved?

I looked up the documentation for this and found

IPage getPage(java.lang.String name)
Returns the page with the given name. If the page has been previously
loaded in the current request cycle, that page is returned. Otherwise,
the engine's page loader is used to load the page.

Thanks, Karthik

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


Re: tapestry 4.0.2: How do I get a new page object?

Posted by Christian Haselbach <ch...@tngtech.com>.
On Tue, Apr 17, 2007 at 11:30:03AM +0200, Christian Haselbach wrote:
> You can instantiate a page by hand, but this will undermine the caching
> strategy of tapestry. My guess is, that you are better off rethinking
> your method of resolution.

Perhaps you can put your things into points like prepareForRender() and
cleanupAfterRender()?

Regards,
Christian
-- 
Christian Haselbach - christian.haselbach@tngtech.com - +49 176 2082 5804
TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterföhring
Geschäftsführer: Henrik Klagges, Gerhard Müller, Eike Reinel
Amtsgericht München, HRB 135082

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


Re: tapestry 4.0.2: How do I get a new page object?

Posted by Christian Haselbach <ch...@tngtech.com>.
On Tue, Apr 17, 2007 at 03:02:15PM +0530, Karthik N wrote:
> would you happen to know how i could achieve that?

It is not that easy and it would be a horrible hack. If you want to do
it non the less, have a look at PageSource.getPage() to get an idea
what needs to be done.

However, it would probably make more sense to try and fit your
initilization and destruction into the lifecycle of the tapestry
objects instead of working around (and against) the framework.

If you could be more specific about your real problem, it might be
possible to show you an alternative.

Regards,
Christian
-- 
Christian Haselbach - christian.haselbach@tngtech.com - +49 176 2082 5804
TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterföhring
Geschäftsführer: Henrik Klagges, Gerhard Müller, Eike Reinel
Amtsgericht München, HRB 135082

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


Re: tapestry 4.0.2: How do I get a new page object?

Posted by Karthik N <ka...@gmail.com>.
> You can instantiate a page by hand, but this will undermine the caching
> strategy of tapestry. My guess is, that you are better off rethinking
> your method of resolution.
>

would you happen to know how i could achieve that?

my requirement might not necessarily undermine tapestry's caching
strategy - because  all i want is a *different* instance of the page -
if the page pool has another instance i could very well use it.

it's just that i want to avoid using the same page object.

any pointers would be most appreciated, thanks!

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


Re: tapestry 4.0.2: How do I get a new page object?

Posted by Christian Haselbach <ch...@tngtech.com>.
On Tue, Apr 17, 2007 at 02:22:19PM +0530, Karthik N wrote:
> this is done both when a new page is created and before an existing
> page is retired to the pool
> 
> now the problem is that when the same page object is returned, our
> retirement/creation logic is affected

I have no idea what the purpose of your strategy is, but it seems to me
that you are trying something that is not compatible with the lifecycle
of tapestry pages.

> hence we're looking for a way to create a new instance of the page
> even though the cycle might already have instantiated the page once
> before

You can instantiate a page by hand, but this will undermine the caching
strategy of tapestry. My guess is, that you are better off rethinking
your method of resolution.

Regards,
Christian

-- 
Christian Haselbach - christian.haselbach@tngtech.com - +49 176 2082 5804
TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterföhring
Geschäftsführer: Henrik Klagges, Gerhard Müller, Eike Reinel
Amtsgericht München, HRB 135082

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


Re: tapestry 4.0.2: How do I get a new page object?

Posted by Karthik N <ka...@gmail.com>.
we have certain actions we perform in the tapestry lifecycle methods
that are application-specific

this is done both when a new page is created and before an existing
page is retired to the pool

now the problem is that when the same page object is returned, our
retirement/creation logic is affected

hence we're looking for a way to create a new instance of the page
even though the cycle might already have instantiated the page once
before

Thanks, karthik


On 4/16/07, Christian Haselbach <ch...@tngtech.com> wrote:
> Quoting Karthik N <ka...@gmail.com>:
>
> > I have a requirement however where I want newPage to be a different
> > instance than this
>
> In that case you should probably rethink the requirement. Why do you
> want to have a different instance? The concept of the page is that you
> have an instance to render for the user and then it is returned to the
> page pool.
>
> > Any ideas how this can be achieved?
>
> You could turn off the cache, but this is most certainly not what you
> want.
>
> Regards,
> Christian
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Thanks, Karthik

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


Re: tapestry 4.0.2: How do I get a new page object?

Posted by Christian Haselbach <ch...@tngtech.com>.
On Tue, Apr 17, 2007 at 10:39:38AM +0200, Holger Stolzenberg wrote:
> How about:
> 
> @InjectPage("PageName")
> public abstract IPage getNewPageObject();

This will not necessarily give you a new instance as the OP wanted.

Regards,
Christian
-- 
Christian Haselbach - christian.haselbach@tngtech.com - +49 176 2082 5804
TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterföhring
Geschäftsführer: Henrik Klagges, Gerhard Müller, Eike Reinel
Amtsgericht München, HRB 135082

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


AW: tapestry 4.0.2: How do I get a new page object?

Posted by Holger Stolzenberg <h....@ewerk.com>.
How about:

@InjectPage("PageName")
public abstract IPage getNewPageObject();



Mit lieben Grüßen aus dem eWerk

  |  Holger Stolzenberg
  |  Softwareentwickler
  |
  |  Geschäftsführer: 
  |  Frank Richter, Erik Wende, Hendrik Schubert
  |
  |  eWerk IT GmbH
  |  Markt 16
  |  Leipzig 04109
  |  http://www.ewerk.com
  |  HRB 9065, AG Leipzig
  |  Hauptniederlassung Leipzig
  |
  |  fon +49.341.4 26 49-0
  |  fax +49.341.4 26 49-88
  |  mailto:h.stolzenberg@ewerk.com
  |
  |  Support:
  |  fon 0700 CALLME24 (0700 22556324)
  |  fax 0700 CALLME24 (0700 22556324)
  |
  | Auskünfte und Angebote per Mail
  | sind freibleibend und unverbindlich. 

-----Ursprüngliche Nachricht-----
Von: Christian Haselbach [mailto:christian.haselbach@tngtech.com] 
Gesendet: Montag, 16. April 2007 14:25
An: Tapestry users
Betreff: Re: tapestry 4.0.2: How do I get a new page object?

Quoting Karthik N <ka...@gmail.com>:

> I have a requirement however where I want newPage to be a different 
> instance than this

In that case you should probably rethink the requirement. Why do you want to have a different instance? The concept of the page is that you have an instance to render for the user and then it is returned to the page pool.

> Any ideas how this can be achieved?

You could turn off the cache, but this is most certainly not what you want.

Regards,
Christian

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


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


Re: tapestry 4.0.2: How do I get a new page object?

Posted by Christian Haselbach <ch...@tngtech.com>.
Quoting Karthik N <ka...@gmail.com>:

> I have a requirement however where I want newPage to be a different
> instance than this

In that case you should probably rethink the requirement. Why do you
want to have a different instance? The concept of the page is that you
have an instance to render for the user and then it is returned to the
page pool.

> Any ideas how this can be achieved?

You could turn off the cache, but this is most certainly not what you
want.

Regards,
Christian

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