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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to