I don't think there's any easy way of doing it programmatically, but you can replace those two annotations with xml in your .page file.

instead of @InjectObject, use <inject .../>:
http://jakarta.apache.org/tapestry/UsersGuide/spec.html#spec.inject

instead of @Persist, use <property persist="client" .../> (or persist="session")
http://jakarta.apache.org/tapestry/UsersGuide/spec.html#spec.property

Martin

On Mon, 10 Apr 2006 05:44:02 +0300, Mark <[EMAIL PROTECTED]> wrote:

Thanks for the help.

What's the easiest way to get these two things done programmatically without annotations?

MARK



I guess you could do that, but if you only need the objects on the result page, you should probably just use @Persist on their corresponding getters in your page class: http://jakarta.apache.org/tapestry/tapestry-annotations/index.html#Persist Tapestry will then encode the object in the redirect url and make sure it's recreated on the next request.


getPageService() doesn't exist anywhere, I added it in my example code:

@InjectObject("engine-service:page")
public abstract IEngineService getPageService();

This tells Tapestry to make sure that when you call getPageService(), you will get the engine service called "page", which happens to be the engine service that handles normal page requests. :) You then call getLink(...) on that service to get a link to the page called "YourResultPage".

Martin

On Mon, 10 Apr 2006 04:47:31 +0300, Mark <[EMAIL PROTECTED]> wrote:

Hi Martin,

thanks for the response. So if during saving, I create a bunch of objects that I need to render the result page, for example some messages, etc; do I have to put these in the Visit/Session and then get them back out in the next page that I redirect to?

Thanks,

MARK


Hi Mark.
If you make your form listener return an ILink, tapestry will redirect the client to the new URL and any subsequent "refresh" will only reload that page, not submit the form again.
Simple example:

public ILink submit()
{
    addStuffToDatabase();

    return getPageService().getLink(false, "YourResultPage");
}

@InjectObject("engine-service:page")
public abstract IEngineService getPageService();



You can also throw a RedirectException if you want, it sends a HTTP redirect to the client. You're thinking of a PageRedirectException, which is handled internally.

Martin

On Mon, 10 Apr 2006 01:47:51 +0300, Mark <[EMAIL PROTECTED]> wrote:

Hi,

I just searched for a solution for this problem in the archive, but did not find anything that seemed to work:

Assume I have a request that adds or deletes a record to/from the database. The request gets executed, record gets added or deleted and a comfirmation is displayed. If the user now hits the F5 key or the "Reload" or "Refresh" button of the browser, the request is sent to the server again, causing the record to be added or deleted (which will of course fail since the record is already gone) again.

I did find a number of posts regarding this, but most of them ended in the recommendation to use a RedirectException in the add/delete page after the add/delete has been performed. However, I do not see how this would help, since the RedirectException is executed internally by Tapestry, not by the Browser.

This post here describes how to reproduce the problem using the VLib project that comes with Tapestry: http://article.gmane.org/gmane.comp.java.tapestry.user/7224/match=browser+refresh This post seems to have a solution, but it is quite complex and outdated (from 2003), so I am wondering if T4 has a better solution in the meantime? http://article.gmane.org/gmane.comp.java.tapestry.user/3580/match=contribute+action+link Thanks,

MARK




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to