BlackMario
BlackMario

Reputation: 55

How to transfer some information between 2 pages or more ?

I'm *currently learning how to use tapestry 5.3.6 and i have one issue. I need to share information between 2 pages to do a full registration for a user to a fake mobile operator and i don't know what is the right way to do this, firstly i thought that the @Persist could do this trick but i realized that this annotation keep information for a specific page eand don't share it with other pages... I think the @SessionStated is the answer but i'm not sure :/

Here is a schema to illustrate my needing :

First page : "personnal information" => Second page "credit card information" => Third page : "Resume and policies acceptation before final submission"

I hope that you can help me... Thanks a lot !

Upvotes: 0

Views: 686

Answers (2)

BlackMario
BlackMario

Reputation: 55

We can do this with various method which are explained on this link : http://jumpstart.doublenegative.com.au/jumpstart/examples/state/passingbypersist

We can use the session, or use the @Persist, for the persist method we need to implement a public method to pass parameters to the next page which is going to be called.

The second solution was the solution I was looking for.

Upvotes: 1

sody
sody

Reputation: 3791

You can do this with @SessionAttribute, @SessionState and through Session.

  1. Session attributes:

    @SessionAtribute("myObject")
    private MyObject myObject;
    
  2. Session-wide objects:

    @SessionState
    private MyObject myObject;
    
  3. Session API:

    @Inject
    private Request request;
    
    void someMethod() {
      final Session session = request.getSession(true);
      session.setAttribute("myObject", myObject);
    }
    

More information here

Upvotes: 2

Related Questions