You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Szemere Szemere <sz...@googlemail.com> on 2008/01/29 10:29:35 UTC

Re: Editing a collection

I'm going through something similar right now. Looking at the docs:

http://tapestry.apache.org/tapestry5/tapestry-core/component-parameters.html#orgapachetapestrycorelibcomponentstextfield

it seems that your:

value="user.loginUser"

determines the field that gets updated when the form is submitted. So as
you've got 6x fields that point to the same field in your form, that's what
gets updated (take a peek at 'user' to confirm this).

I think you need to override the 'value' setting to point to your different
objects.

Re: Editing a collection

Posted by Grigoris Ioannou <ho...@gmail.com>.
Same problem here.

I have a reservation form where the number of the guests is variable. So, in
my CustomerDetails.tml I have inside a form:

                <t:loop source="guests" value="guest">
                  <tr>
                    <td>Name</td>
                    <td>
                      <t:textfield t:id="guestName" value="guest.name"
validate="required"/>
                    </td>
                  </tr>
                </t:loop>

In CustomerDetails.java the code that is executed when the form is submitted
is:

    Object onSuccess() {
        System.out.println("guests are now ");
        for (Guest g : getGuests()) {
            System.out.println(g.getName());
        }
...
   }
....
The number of the guests is known beforehand and is set at the page's
onActivate:
public Object onActivate() {
             List<Guest> guests = new ArrayList();
            for (int i = 0; i < getMaxGuests().intValue(); i++) {
                Guest guest = new Guest();
                guests.add(guest);
            }
            setGuests(guests);
}


Nevertheless, the names of the guests are always null. Perhaps this is not
the "right" way to enter multiple values? Any suggestions?

Regards,
Grigoris


On Tue, Jan 29, 2008 at 4:19 PM, Michael Courcy <mi...@gmail.com>wrote:

> Hi François
>
> Thanks a lot, but actually my goal was more on understanding the loop
> inside the form and how the model is updated in such situation.
>
> I keep your link though, I'll have a look on it.
>
>
> Michael.
>
> Francois Armand a écrit :
>
>  Michael Courcy wrote:
>>
>>> You mean that using value="user.loginUser" tapestry alway update the same
>>> thing.
>>> Thus if I change the method
>>>
>>> User {
>>> void setLoginUser(String loginUser){
>>>  this.loginUser = loginUser;
>>>  System.out.println(loginUser);
>>> }
>>>
>>> It should at least output the value I input in my textField ...
>>> And that's right, it actually what's going on the input are correctly
>>> output
>>>
>>> But When I outout the user itself in the page
>>>
>>> public void setUser(User user) {
>>>       this.user = user;
>>>       System.out.println(user);
>>>   }
>>>
>>> the old value is kept
>>>
>>> actually setUser is call before setLoginUser ...
>>>
>>> Ok thanks I've to work on that.
>>>
>>
>> If you want, I built a "ListEditor" to handle this kind of things. It's
>> part of my project, http://interldap.org
>> What you may looking for is here :
>> http://svn.forge.objectweb.org/cgi-bin/viewcvs.cgi/interldap/interldap-wui-common/trunk/src/main/java/org/interldap/wui/t5lib/components/ListEditor.java?view=markup&rev=672
>> And here there is an example of use case (it really lacks a lot of doc) :
>>
>> http://svn.forge.objectweb.org/cgi-bin/viewcvs.cgi/interldap/interldap-wui-common/trunk/src/main/resources/org/interldap/wui/t5lib/components/eschema/EditAttribute.tml?view=markup&rev=568
>>
>> That build a list of input fields, with a [delete] button next to them,
>> and [add new value] button at the end of the list.
>> Each button emits an events so that enclosing component can add or delete
>> matching value from list.
>> When you click on a button, updated values are set in the list at the
>> right place.
>>
>> It may be use to construct simpler list editor.
>>
>> Hope it may help !
>>
>>
>
> --
> Michael Courcy
> http://courcy.blogspot.com
> http://courcy-en.blogspot.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Nikolaos Konstantinou
PhD Student - Research Assistant
http://www.cn.ntua.gr/~nkons

Re: Editing a collection

Posted by Michael Courcy <mi...@gmail.com>.
Hi François

Thanks a lot, but actually my goal was more on understanding the loop 
inside the form and how the model is updated in such situation.

I keep your link though, I'll have a look on it.


Michael.

Francois Armand a écrit :
> Michael Courcy wrote:
>> You mean that using value="user.loginUser" tapestry alway update the 
>> same thing.
>> Thus if I change the method
>>
>> User {
>> void setLoginUser(String loginUser){
>>   this.loginUser = loginUser;
>>   System.out.println(loginUser);
>> }
>>
>> It should at least output the value I input in my textField ...
>> And that's right, it actually what's going on the input are correctly 
>> output
>>
>> But When I outout the user itself in the page
>>
>> public void setUser(User user) {
>>        this.user = user;
>>        System.out.println(user);
>>    }
>>
>> the old value is kept
>>
>> actually setUser is call before setLoginUser ...
>>
>> Ok thanks I've to work on that.
>
> If you want, I built a "ListEditor" to handle this kind of things. 
> It's part of my project, http://interldap.org
> What you may looking for is here : 
> http://svn.forge.objectweb.org/cgi-bin/viewcvs.cgi/interldap/interldap-wui-common/trunk/src/main/java/org/interldap/wui/t5lib/components/ListEditor.java?view=markup&rev=672 
>
> And here there is an example of use case (it really lacks a lot of doc) :
> http://svn.forge.objectweb.org/cgi-bin/viewcvs.cgi/interldap/interldap-wui-common/trunk/src/main/resources/org/interldap/wui/t5lib/components/eschema/EditAttribute.tml?view=markup&rev=568 
>
>
> That build a list of input fields, with a [delete] button next to 
> them, and [add new value] button at the end of the list.
> Each button emits an events so that enclosing component can add or 
> delete matching value from list.
> When you click on a button, updated values are set in the list at the 
> right place.
>
> It may be use to construct simpler list editor.
>
> Hope it may help !
>


-- 
Michael Courcy
http://courcy.blogspot.com
http://courcy-en.blogspot.com


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


Re: Editing a collection

Posted by Francois Armand <fa...@linagora.com>.
Michael Courcy wrote:
> You mean that using value="user.loginUser" tapestry alway update the 
> same thing.
> Thus if I change the method
>
> User {
> void setLoginUser(String loginUser){
>   this.loginUser = loginUser;
>   System.out.println(loginUser);
> }
>
> It should at least output the value I input in my textField ...
> And that's right, it actually what's going on the input are correctly 
> output
>
> But When I outout the user itself in the page
>
> public void setUser(User user) {
>        this.user = user;
>        System.out.println(user);
>    }
>
> the old value is kept
>
> actually setUser is call before setLoginUser ...
>
> Ok thanks I've to work on that.

If you want, I built a "ListEditor" to handle this kind of things. It's 
part of my project, http://interldap.org
What you may looking for is here : 
http://svn.forge.objectweb.org/cgi-bin/viewcvs.cgi/interldap/interldap-wui-common/trunk/src/main/java/org/interldap/wui/t5lib/components/ListEditor.java?view=markup&rev=672
And here there is an example of use case (it really lacks a lot of doc) :
http://svn.forge.objectweb.org/cgi-bin/viewcvs.cgi/interldap/interldap-wui-common/trunk/src/main/resources/org/interldap/wui/t5lib/components/eschema/EditAttribute.tml?view=markup&rev=568

That build a list of input fields, with a [delete] button next to them, 
and [add new value] button at the end of the list.
Each button emits an events so that enclosing component can add or 
delete matching value from list.
When you click on a button, updated values are set in the list at the 
right place.

It may be use to construct simpler list editor.

Hope it may help !

-- 
Francois Armand
Etudes & Développements J2EE
Groupe Linagora - http://www.linagora.com
Tél.: +33 (0)1 58 18 68 28
-----------
InterLDAP - http://interldap.org 
FederID - http://www.federid.org/
Open Source identities management and federation


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


Re: Editing a collection

Posted by Michael Courcy <mi...@gmail.com>.
You mean that using value="user.loginUser" tapestry alway update the 
same thing.
Thus if I change the method

User {
 void setLoginUser(String loginUser){
   this.loginUser = loginUser;
   System.out.println(loginUser);
 }

It should at least output the value I input in my textField ...
And that's right, it actually what's going on the input are correctly 
output

But When I outout the user itself in the page

public void setUser(User user) {
        this.user = user;
        System.out.println(user);
    }

the old value is kept

actually setUser is call before setLoginUser ...

Ok thanks I've to work on that.


Szemere Szemere a écrit :
> I'm going through something similar right now. Looking at the docs:
>
> http://tapestry.apache.org/tapestry5/tapestry-core/component-parameters.html#orgapachetapestrycorelibcomponentstextfield
>
> it seems that your:
>
> value="user.loginUser"
>
> determines the field that gets updated when the form is submitted. So as
> you've got 6x fields that point to the same field in your form, that's what
> gets updated (take a peek at 'user' to confirm this).
>
> I think you need to override the 'value' setting to point to your different
> objects.
>
>   


-- 
Michael Courcy
http://courcy.blogspot.com
http://courcy-en.blogspot.com


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