You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Stephan Windmüller <st...@cs.tu-dortmund.de> on 2009/07/21 18:31:58 UTC
Passing data to the same page - Understanding PersistanceContext.FLASH
Hello!
On a page I want the user to create a new task and add users to it. The
list of users should be extended with a button "Add another user" and is
displayed through a loop component.
| <tr t:type="loop" t:source="users" value="user" encoder="encoder">
| <td>
| <t:textfield t:id="firstname" size="15" value="user.firstname"/>
| </td>
| <td>
| <t:textfield t:id="lastname" size="15" value="user.lastname"/>
| </td>
| <td>
| <t:textfield t:id="mailAddress" size="40" value="user.mailAddress"/>
| </td>
| </tr>
| <tr>
| <td colspan="3">
| <input t:type="Submit" t:id="addUser" value="${message:addUser}"/>
| </td>
| </tr>
To realize this I annotated the task and the list of users with
@Persist(PersistanceConstants.FLASH)and added a method set(task,
List<User>) to the submit logic of the form.
| @Persist(PersistenceConstants.FLASH)
| @Property
| private Task task;
|
| @Persist(PersistenceConstants.FLASH)
| @Property
| private List<User> users;
|
| void set(Task task, List<User> users) {
| this.task = task;
| this.users = users;
| }
Now when I click the "Add another user" button the task data is
correctly restored and put into the form. Also the first user is
displayed correctly.
| @OnEvent(value = "selected", component = "addUser")
| void addUserObject() {
| users.add(new User());
|
| users = newUsers;
|
| newTaskPage.set(task, users);
| nextPage = newTaskPage;
| }
But when I enter another user and press the button "Add another user"
once again, this user is not stored. Instead, the onActivate method
tells me that the list of users is null during activation. Why is that?
On the web I found several instructions on how to pass data to other
pages, but not to the same page.
>From what I understood is that PersistanceConstants.FLASH stores the
data in the session for the next request. This is only correctly set if
I use @InjectPage and a set-method, correct? But why can I use my task
object over several requests and the user list only once?
All I am dealing with are a number of strings which are always part of
the form so I do not need client persistence. How can I store them
correctly?
TIA
Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
RE: Passing data to the same page - Understanding
PersistanceContext.FLASH
Posted by De Saint Steban Emmanuel <em...@atosorigin.com>.
-----Message d'origine-----
De : Stephan Windmüller [mailto:stephan.windmueller@cs.tu-dortmund.de]
Envoyé : mercredi 22 juillet 2009 10:50
À : Tapestry users
Objet : Re: Passing data to the same page - Understanding PersistanceContext.FLASH
De Saint Steban Emmanuel wrote:
> PersistanceContext.FLASH is storing the object for only one time.
> The data will be deleted after the first access.
Okay, but what is meant by "first access"? Even writing the data with a
debug logger? Or after the onActivate-method is finished? Is there a way
to keep the data in the page and pass it with the next request?
As says in the Tapestry documentation : http://tapestry.apache.org/tapestry5/guide/persist.html
flash strategy
The flash strategy stores information in the session as well, just for not very long. Values are stored into the session, but then deleted from the session as they are first used to restore a page's state.
The flash is typically used to store temporary messages that should only be displayed to the user once.
To keep data in the session just use @Persist by default is session persist. If you want to force session use @Persist("session")
> Use just @Persist (or if you want to access in all page of your
> application use @ApplicationState
This would break the use of multiple tabs, because I would only have one
store for many pages.
For one store for many page use @ApplicationState (it is store in the session) But you can use it in different page.
In each page, juste use
@ApplicationState
private type var;
Juste keep in mind that you can use a type only one time. Tapestry use the type to differences the different variable, not the name.
In exemple : You cant have to variable with the same type String. The two variable will be the same.
Emmanuel
Ce message et les pièces jointes sont confidentiels et réservés à l'usage exclusif de ses destinataires. Il peut également être protégé par le secret professionnel. Si vous recevez ce message par erreur, merci d'en avertir immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant être assurée sur Internet, la responsabilité du groupe Atos Origin ne pourra être recherchée quant au contenu de ce message. Bien que les meilleurs efforts soient faits pour maintenir cette transmission exempte de tout virus, l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne saurait être recherchée pour tout dommage résultant d'un virus transmis.
This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Atos Origin group liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Passing data to the same page - Understanding PersistanceContext.FLASH
Posted by Stephan Windmüller <st...@cs.tu-dortmund.de>.
De Saint Steban Emmanuel wrote:
> PersistanceContext.FLASH is storing the object for only one time.
> The data will be deleted after the first access.
Okay, but what is meant by "first access"? Even writing the data with a
debug logger? Or after the onActivate-method is finished? Is there a way
to keep the data in the page and pass it with the next request?
> Use just @Persist (or if you want to access in all page of your
> application use @ApplicationState
This would break the use of multiple tabs, because I would only have one
store for many pages.
- Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
RE: Passing data to the same page - Understanding
PersistanceContext.FLASH
Posted by De Saint Steban Emmanuel <em...@atosorigin.com>.
PersistanceContext.FLASH is storing the object for only one time. The data will be deleted after the first access.
Use just @Persist (or if you want to access in all page of your application use @ApplicationState
Emmanuel
Ce message et les pi?ces jointes sont confidentiels et r?serv?s ? l'usage exclusif de ses destinataires. Il peut ?galement ?tre prot?g? par le secret professionnel. Si vous recevez ce message par erreur, merci d'en avertir imm?diatement l'exp?diteur et de le d?truire. L'int?grit? du message ne pouvant ?tre assur?e sur Internet, la responsabilit? du groupe Atos Origin ne pourra ?tre recherch?e quant au contenu de ce message. Bien que les meilleurs efforts soient faits pour maintenir cette transmission exempte de tout virus, l'exp?diteur ne donne aucune garantie ? cet ?gard et sa responsabilit? ne saurait ?tre recherch?e pour tout dommage r?sultant d'un virus transmis.
This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Atos Origin group liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Passing data to the same page - Understanding
PersistanceContext.FLASH
Posted by Kalle Korhonen <ka...@gmail.com>.
Or, you can use a conversational scope - stored in session but as part
of separate scope which can be set to expire earlier than the session
itself. The library also supports multiple simultaneous conversations
on different browser tabs. More at
http://docs.codehaus.org/display/TRAILS/Conversations+in+Trails.
Kalle
On Wed, Jul 22, 2009 at 4:19 PM, Thiago H. de Paula
Figueiredo<th...@gmail.com> wrote:
> Em Wed, 22 Jul 2009 05:51:23 -0300, Stephan Windmüller
> <st...@cs.tu-dortmund.de> escreveu:
>
>> It is really necessary to use a persistent store when all needed data is
>> transmitted with each submit of the form?
>
> Tapestry does redirect-after-post by default, so some form of persistence is
> needed. You can also use the activation context to pass this information
> back to the page whithout usin @Persist or @SessionState.
>
> You can disable redirect-after-post (documentation at
> http://tapestry.apache.org/tapestry5.1/guide/conf.html), but I don't
> recommend this option.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
>
> ---------------------------------------------------------------------
> 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: Passing data to the same page - Understanding
PersistanceContext.FLASH
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Wed, 22 Jul 2009 05:51:23 -0300, Stephan Windmüller
<st...@cs.tu-dortmund.de> escreveu:
> It is really necessary to use a persistent store when all needed data is
> transmitted with each submit of the form?
Tapestry does redirect-after-post by default, so some form of persistence
is needed. You can also use the activation context to pass this
information back to the page whithout usin @Persist or @SessionState.
You can disable redirect-after-post (documentation at
http://tapestry.apache.org/tapestry5.1/guide/conf.html), but I don't
recommend this option.
--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Passing data to the same page - Understanding PersistanceContext.FLASH
Posted by Stephan Windmüller <st...@cs.tu-dortmund.de>.
Kristian Marinkovic schrieb:
> you can use PersistenceConstants.CLIENT to store all your data
> on the client side - with all iths pros and cons.
This creates a very long URL. I found no way to force client persistence
into a form.
> another way - when using a form - you can use the onPrepare,
> onPrepareForRender and onPrepareForSubmit events to load
> the previous created/saved list from a persistent store.
It is really necessary to use a persistent store when all needed data is
transmitted with each submit of the form?
Regards
Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Passing data to the same page - Understanding PersistanceContext.FLASH
Posted by Kristian Marinkovic <kr...@porsche.co.at>.
you can use PersistenceConstants.CLIENT to store all your data
on the client side - with all iths pros and cons.
or can store your data in the session wia SESSION or as
SessionStateObject
another way - when using a form - you can use the onPrepare,
onPrepareForRender and onPrepareForSubmit events to load
the previous created/saved list from a persistent store.
g,
kris
Stephan Windmüller <st...@cs.tu-dortmund.de>
22.07.2009 10:14
Bitte antworten an
"Tapestry users" <us...@tapestry.apache.org>
An
Tapestry users <us...@tapestry.apache.org>
Kopie
Thema
Re: Passing data to the same page - Understanding PersistanceContext.FLASH
Kristian Marinkovic wrote:
> in your case you'd need the session scope (=default)
But this will break if the user is creating several tasks in multiple
browser tabs.
When I summarize my issue it all comes to the following question: How do
I access data that is stored in objects and submitted completely with a
form after the submit without storing the data in the session?
I refuse to accept that Tapestry cannot handle this. There must be an
error in my code. The task data for example is completely restored with
PersistenceConstants.FLASH, but the List of users is not.
Regards
Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Passing data to the same page - Understanding PersistanceContext.FLASH
Posted by Stephan Windmüller <st...@cs.tu-dortmund.de>.
Kristian Marinkovic wrote:
> in your case you'd need the session scope (=default)
But this will break if the user is creating several tasks in multiple
browser tabs.
When I summarize my issue it all comes to the following question: How do
I access data that is stored in objects and submitted completely with a
form after the submit without storing the data in the session?
I refuse to accept that Tapestry cannot handle this. There must be an
error in my code. The task data for example is completely restored with
PersistenceConstants.FLASH, but the List of users is not.
Regards
Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Passing data to the same page - Understanding PersistanceContext.FLASH
Posted by Kristian Marinkovic <kr...@porsche.co.at>.
Tapestry 5 handles action requests and page requests.
action requests identify a certain component or event
that will be used to process the request. if the component
request has been processed a redirect (= second request)
page request is generated and issued. the flash persistence
strategy is used to store the data between the action request
and the redirect page request. in your case you'd need the
session scope (=default)
search the mailing list for more details
g,
kris
Stephan Windmüller <st...@cs.tu-dortmund.de>
21.07.2009 18:31
Bitte antworten an
"Tapestry users" <us...@tapestry.apache.org>
An
Tapestry users <us...@tapestry.apache.org>
Kopie
Thema
Passing data to the same page - Understanding PersistanceContext.FLASH
Hello!
On a page I want the user to create a new task and add users to it. The
list of users should be extended with a button "Add another user" and is
displayed through a loop component.
| <tr t:type="loop" t:source="users" value="user" encoder="encoder">
| <td>
| <t:textfield t:id="firstname" size="15" value="user.firstname"/>
| </td>
| <td>
| <t:textfield t:id="lastname" size="15" value="user.lastname"/>
| </td>
| <td>
| <t:textfield t:id="mailAddress" size="40" value="user.mailAddress"/>
| </td>
| </tr>
| <tr>
| <td colspan="3">
| <input t:type="Submit" t:id="addUser" value="${message:addUser}"/>
| </td>
| </tr>
To realize this I annotated the task and the list of users with
@Persist(PersistanceConstants.FLASH)and added a method set(task,
List<User>) to the submit logic of the form.
| @Persist(PersistenceConstants.FLASH)
| @Property
| private Task task;
|
| @Persist(PersistenceConstants.FLASH)
| @Property
| private List<User> users;
|
| void set(Task task, List<User> users) {
| this.task = task;
| this.users = users;
| }
Now when I click the "Add another user" button the task data is
correctly restored and put into the form. Also the first user is
displayed correctly.
| @OnEvent(value = "selected", component = "addUser")
| void addUserObject() {
| users.add(new User());
|
| users = newUsers;
|
| newTaskPage.set(task, users);
| nextPage = newTaskPage;
| }
But when I enter another user and press the button "Add another user"
once again, this user is not stored. Instead, the onActivate method
tells me that the list of users is null during activation. Why is that?
On the web I found several instructions on how to pass data to other
pages, but not to the same page.
>From what I understood is that PersistanceConstants.FLASH stores the
data in the session for the next request. This is only correctly set if
I use @InjectPage and a set-method, correct? But why can I use my task
object over several requests and the user list only once?
All I am dealing with are a number of strings which are always part of
the form so I do not need client persistence. How can I store them
correctly?
TIA
Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org