You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by limonn <li...@gmail.com> on 2009/09/12 16:15:35 UTC

form that create an object

I want to have a form that represent an object, so far I have something but
is not working.

<form t:type="form" t:id="userForm">

name : <input type="text" t:type="textfield" t:id="${user.name}"/>

<br/>

last name : <input type="text" t:type="textfield" t:id="${user.lastname}"/>

<br/>


<input t:type="submit" value="Update"   t:id="update" />
<input t:type="submit" value="Cancel"   t:id="cancel"  />

</form>

----------------------------------------------------------------

and java 

(User.java is a regular class with 2 String properties name and lastName
getters and setters )


the java page


import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Persist;

import com.limonn.entities.User;

public class Form {
   
    private boolean cancel;
   
    @InjectPage
    private Index index;
   
   
     @Persist
    private User user;
   
   
     public User getUser() {
        return user;
    }


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

   
 
void onSelectedFromUpdate() {
     cancel = false;
   
  }    
  void onSelectedFromCancel() {
     cancel = true;
  }

  Object  onSuccess() {
     if (cancel) {
         
         System.out.print(" name was : " + this.user.getName() + " from
success");
    
     } else {
         
         System.out.print(" name was : " + this.user.getName() + " from
cancel");
         
     } 
     return index;
  }

---------------------------------------------------------------------------------------------------
               how you get the user.name and user.lastName as properties
from User as object from the form ?

Thank 's in advance
-- 
View this message in context: http://www.nabble.com/form-that-create-an-object-tp25414886p25414886.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: form that create an object

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Fri, 25 Sep 2009 10:50:59 -0300, limonn <li...@gmail.com> escreveu:

> I understand that but my problem it is only to create an object, I dont  
> know how to code a form with the object properties and many buttons and  
> receive them in java the whole as an object.

Take a look at the tutorial:  
http://tapestry.apache.org/tapestry5.1/tutorial1/forms.html and the  
BeanEditForm guide:  
http://tapestry.apache.org/tapestry5.1/guide/beaneditform.html

-- 
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: form that create an object

Posted by limonn <li...@gmail.com>.
I understand that but my problem it is only to create an object, I dont know
how to code a form with the object properties and many buttons and receive
them in java the whole as an object.




Thiago H. de Paula Figueiredo wrote:
> 
> Em Fri, 25 Sep 2009 10:24:56 -0300, limonn <li...@gmail.com>
> escreveu:
> 
>> Ok I m not editing so no need to use value, however it looks like there  
>> is no way in tapestry to receive an object as described above ( straight  
>> from a
>> form as BeanEditForm, that I can't use because I need many submit  
>> buttons) m I correct ?
> 
> Yes. But, to edit an object, you can use a Form and a BeanEditor and then  
> have some Submit components inside the Form. BeanEditForm is just a Form  
> with a BeanEditor and a submit button inside.
> If you just want to show an object, use BeanDisplay.
> 
> -- 
> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/form-that-create-an-object-tp25414886p25612509.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: form that create an object

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Fri, 25 Sep 2009 10:24:56 -0300, limonn <li...@gmail.com> escreveu:

> Ok I m not editing so no need to use value, however it looks like there  
> is no way in tapestry to receive an object as described above ( straight  
> from a
> form as BeanEditForm, that I can't use because I need many submit  
> buttons) m I correct ?

Yes. But, to edit an object, you can use a Form and a BeanEditor and then  
have some Submit components inside the Form. BeanEditForm is just a Form  
with a BeanEditor and a submit button inside.
If you just want to show an object, use BeanDisplay.

-- 
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: form that create an object

Posted by limonn <li...@gmail.com>.
Ok I m not editing so no need to use value, however it looks like there is no
way in tapestry to receive an object as described above ( straight from a
form as BeanEditForm, that I can't use because I need many submit buttons)

m I correct ?

 

Thiago H. de Paula Figueiredo wrote:
> 
> Em Thu, 24 Sep 2009 10:53:41 -0300, limonn <li...@gmail.com>
> escreveu:
> 
>>             <t:TextField t:id="user.lastName"  
>> t:validate="required,minlength=3" size="30"/>
>> Failure parsing template context:TestForm.tml: Component id  
>> 'user.lastName' is not valid; component ids must be valid Java  
>> identifiers: start with a
>> letter, and consist of letters, numbers and underscores.
> 
> The t:id must be a valid identifier. You should use the value parameter to  
> bind the textfield to a property: value="user.lastName".
> 
> -- 
> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/form-that-create-an-object-tp25414886p25612127.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: form that create an object

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 24 Sep 2009 10:53:41 -0300, limonn <li...@gmail.com> escreveu:

>             <t:TextField t:id="user.lastName"  
> t:validate="required,minlength=3" size="30"/>
> Failure parsing template context:TestForm.tml: Component id  
> 'user.lastName' is not valid; component ids must be valid Java  
> identifiers: start with a
> letter, and consist of letters, numbers and underscores.

The t:id must be a valid identifier. You should use the value parameter to  
bind the textfield to a property: value="user.lastName".

-- 
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: form that create an object

Posted by limonn <li...@gmail.com>.
I have a @Property annotation but still is not working.

I tried many guys and is not working so far the last thing was:

<t:form  object="user" >
            <t:errors/>
            <t:label for="lastName"/>:
            <t:TextField t:id="user.lastName" 
t:validate="required,minlength=3" size="30"/>
            <br/>
            <t:label for="userName"/>:
            <t:TextField t:id="user.username"  
t:validate="required,minlength=3" size="30"/>
            <br/>
            <t:label for="password"/>:
            <t:TextField t:id="user.password"      
t:validate="required,minlength=3" size="30"/>
            <br/>
            <input type="submit" value="Crear usuario"/>
        </t:form>
    </t:layout>

and I get:

Failure parsing template context:TestForm.tml: Component id 'user.lastName'
is not valid; component ids must be valid Java identifiers: start with a
letter, and consist of letters, numbers and underscores.

If I use 

t:id="username"

It said that property is not bound, so is there a way to get an object from
a form like BeanEditForm does using the Form component ? 

Thanks in advance guys



Thiago H. de Paula Figueiredo wrote:
> 
> Em Tue, 22 Sep 2009 05:54:09 -0300, Sergey Didenko  
> <se...@gmail.com> escreveu:
> 
>> Hi Limonn,
>>
>> you need a public setter for your User object.
> 
> Or annotate it with @Property. This only works in Tapestry pages,  
> components and mixins.
> 
> -- 
> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/form-that-create-an-object-tp25414886p25570145.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: form that create an object

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Tue, 22 Sep 2009 05:54:09 -0300, Sergey Didenko  
<se...@gmail.com> escreveu:

> Hi Limonn,
>
> you need a public setter for your User object.

Or annotate it with @Property. This only works in Tapestry pages,  
components and mixins.

-- 
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: form that create an object

Posted by Sergey Didenko <se...@gmail.com>.
Hi Limonn,

you need a public setter for your User object.

> Class com.limonn.pages.Form does not contain a property named 'name' (within
> property expression 'name'). Available properties: class,
> componentResources, user
>
>
> because in the class page I have
>
> private User user
>
> it is the object I want
>

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


Re: form that create an object

Posted by ningdh <ni...@gmail.com>.
Isn't the textfield bound to user.lastName by setting t:value="user.lastName"? Why there is another 'name'?

And remember to initialize an user instance in the prepareForSubmit event handler, then T5 set value of the textfield to its property 'lastName'.

void onPrepareForSubmit() {
    this.user = new User();
}

DH

----- Original Message ----- 
From: "limonn" <li...@gmail.com>
To: <us...@tapestry.apache.org>
Sent: Sunday, September 13, 2009 9:55 PM
Subject: Re: form that create an object



yes but in that case i loose the object, so now I m getting

Class com.limonn.pages.Form does not contain a property named 'name' (within
property expression 'name'). Available properties: class,
componentResources, user


because in the class page I have 

private User user

it is the object I want

I know tapestry does that when using beanEditForm, but I can t use that
because  I need many buttons in the form.

It must be a way !!

DH-14 wrote:
> 
> Hi, t:id should be a valid Java identifier, you should use like
> t:id="lastName"。
> 
> textfield component will map the bean property(lastName) to the form
> field, so you can just think that after form submit, the bean's property
> is properly set. 
> 
> DH
> 
> ----- Original Message ----- 
> From: "limonn" <li...@gmail.com>
> To: <us...@tapestry.apache.org>
> Sent: Sunday, September 13, 2009 7:39 AM
> Subject: Re: form that create an object
> 
> 
>> 
>> is not working I did try 
>> 
>> <input type="text" t:type="textfield" t:value="user.lastName"
>> t:id="user.lastName"/>
>> 
>> but 
>> 
>> Failure parsing template context:Form.tml: Component id 'user.name' is
>> not
>> valid; component ids must be valid Java identifiers: start with a letter,
>> and consist of letters, numbers and underscores
>> 
>> How you get an object from a form ??
>> 
>> Thanks
>> 
>> 
>> 
>> limonn wrote:
>>> 
>>> I want to have a form that represent an object, so far I have something
>>> but is not working.
>>> 
>>> <form t:type="form" t:id="userForm">
>>> 
>>> name : <input type="text" t:type="textfield" t:id="${user.name}"/>
>>> 
>>> <br/>
>>> 
>>> last name : <input type="text" t:type="textfield"
>>> t:id="${user.lastname}"/>
>>> 
>>> <br/>
>>> 
>>> 
>>> <input t:type="submit" value="Update"   t:id="update" />
>>> <input t:type="submit" value="Cancel"   t:id="cancel"  />
>>> 
>>> </form>
>>> 
>>> ----------------------------------------------------------------
>>> 
>>> and java 
>>> 
>>> (User.java is a regular class with 2 String properties name and lastName
>>> getters and setters )
>>> 
>>> 
>>> the java page
>>> 
>>> 
>>> import org.apache.tapestry5.annotations.InjectPage;
>>> import org.apache.tapestry5.annotations.Persist;
>>> 
>>> import com.limonn.entities.User;
>>> 
>>> public class Form {
>>>    
>>>     private boolean cancel;
>>>    
>>>     @InjectPage
>>>     private Index index;
>>>    
>>>    
>>>      @Persist
>>>     private User user;
>>>    
>>>    
>>>      public User getUser() {
>>>         return user;
>>>     }
>>> 
>>> 
>>>     public void setUser(User user) {
>>>         this.user = user;
>>>     }
>>> 
>>>    
>>>  
>>> void onSelectedFromUpdate() {
>>>      cancel = false;
>>>    
>>>   }    
>>>   void onSelectedFromCancel() {
>>>      cancel = true;
>>>   }
>>> 
>>>   Object  onSuccess() {
>>>      if (cancel) {
>>>          
>>>          System.out.print(" name was : " + this.user.getName() + " from
>>> success");
>>>     
>>>      } else {
>>>          
>>>          System.out.print(" name was : " + this.user.getName() + " from
>>> cancel");
>>>          
>>>      } 
>>>      return index;
>>>   }
>>> 
>>> ---------------------------------------------------------------------------------------------------
>>>                how you get the user.name and user.lastName as properties
>>> from User as object from the form ?
>>> 
>>> Thank 's in advance
>>> 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/form-that-create-an-object-tp25414886p25419221.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>>
> 

-- 
View this message in context: http://www.nabble.com/form-that-create-an-object-tp25414886p25423386.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: form that create an object

Posted by limonn <li...@gmail.com>.
yes but in that case i loose the object, so now I m getting

Class com.limonn.pages.Form does not contain a property named 'name' (within
property expression 'name'). Available properties: class,
componentResources, user


because in the class page I have 

private User user

it is the object I want

I know tapestry does that when using beanEditForm, but I can t use that
because  I need many buttons in the form.

It must be a way !!

DH-14 wrote:
> 
> Hi, t:id should be a valid Java identifier, you should use like
> t:id="lastName"。
> 
> textfield component will map the bean property(lastName) to the form
> field, so you can just think that after form submit, the bean's property
> is properly set. 
> 
> DH
> 
> ----- Original Message ----- 
> From: "limonn" <li...@gmail.com>
> To: <us...@tapestry.apache.org>
> Sent: Sunday, September 13, 2009 7:39 AM
> Subject: Re: form that create an object
> 
> 
>> 
>> is not working I did try 
>> 
>> <input type="text" t:type="textfield" t:value="user.lastName"
>> t:id="user.lastName"/>
>> 
>> but 
>> 
>> Failure parsing template context:Form.tml: Component id 'user.name' is
>> not
>> valid; component ids must be valid Java identifiers: start with a letter,
>> and consist of letters, numbers and underscores
>> 
>> How you get an object from a form ??
>> 
>> Thanks
>> 
>> 
>> 
>> limonn wrote:
>>> 
>>> I want to have a form that represent an object, so far I have something
>>> but is not working.
>>> 
>>> <form t:type="form" t:id="userForm">
>>> 
>>> name : <input type="text" t:type="textfield" t:id="${user.name}"/>
>>> 
>>> <br/>
>>> 
>>> last name : <input type="text" t:type="textfield"
>>> t:id="${user.lastname}"/>
>>> 
>>> <br/>
>>> 
>>> 
>>> <input t:type="submit" value="Update"   t:id="update" />
>>> <input t:type="submit" value="Cancel"   t:id="cancel"  />
>>> 
>>> </form>
>>> 
>>> ----------------------------------------------------------------
>>> 
>>> and java 
>>> 
>>> (User.java is a regular class with 2 String properties name and lastName
>>> getters and setters )
>>> 
>>> 
>>> the java page
>>> 
>>> 
>>> import org.apache.tapestry5.annotations.InjectPage;
>>> import org.apache.tapestry5.annotations.Persist;
>>> 
>>> import com.limonn.entities.User;
>>> 
>>> public class Form {
>>>    
>>>     private boolean cancel;
>>>    
>>>     @InjectPage
>>>     private Index index;
>>>    
>>>    
>>>      @Persist
>>>     private User user;
>>>    
>>>    
>>>      public User getUser() {
>>>         return user;
>>>     }
>>> 
>>> 
>>>     public void setUser(User user) {
>>>         this.user = user;
>>>     }
>>> 
>>>    
>>>  
>>> void onSelectedFromUpdate() {
>>>      cancel = false;
>>>    
>>>   }    
>>>   void onSelectedFromCancel() {
>>>      cancel = true;
>>>   }
>>> 
>>>   Object  onSuccess() {
>>>      if (cancel) {
>>>          
>>>          System.out.print(" name was : " + this.user.getName() + " from
>>> success");
>>>     
>>>      } else {
>>>          
>>>          System.out.print(" name was : " + this.user.getName() + " from
>>> cancel");
>>>          
>>>      } 
>>>      return index;
>>>   }
>>> 
>>> ---------------------------------------------------------------------------------------------------
>>>                how you get the user.name and user.lastName as properties
>>> from User as object from the form ?
>>> 
>>> Thank 's in advance
>>> 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/form-that-create-an-object-tp25414886p25419221.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>>
> 

-- 
View this message in context: http://www.nabble.com/form-that-create-an-object-tp25414886p25423386.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: form that create an object

Posted by ningdh <ni...@gmail.com>.
Hi, t:id should be a valid Java identifier, you should use like t:id="lastName"。

textfield component will map the bean property(lastName) to the form field, so you can just think that after form submit, the bean's property is properly set. 

DH

----- Original Message ----- 
From: "limonn" <li...@gmail.com>
To: <us...@tapestry.apache.org>
Sent: Sunday, September 13, 2009 7:39 AM
Subject: Re: form that create an object


> 
> is not working I did try 
> 
> <input type="text" t:type="textfield" t:value="user.lastName"
> t:id="user.lastName"/>
> 
> but 
> 
> Failure parsing template context:Form.tml: Component id 'user.name' is not
> valid; component ids must be valid Java identifiers: start with a letter,
> and consist of letters, numbers and underscores
> 
> How you get an object from a form ??
> 
> Thanks
> 
> 
> 
> limonn wrote:
>> 
>> I want to have a form that represent an object, so far I have something
>> but is not working.
>> 
>> <form t:type="form" t:id="userForm">
>> 
>> name : <input type="text" t:type="textfield" t:id="${user.name}"/>
>> 
>> <br/>
>> 
>> last name : <input type="text" t:type="textfield"
>> t:id="${user.lastname}"/>
>> 
>> <br/>
>> 
>> 
>> <input t:type="submit" value="Update"   t:id="update" />
>> <input t:type="submit" value="Cancel"   t:id="cancel"  />
>> 
>> </form>
>> 
>> ----------------------------------------------------------------
>> 
>> and java 
>> 
>> (User.java is a regular class with 2 String properties name and lastName
>> getters and setters )
>> 
>> 
>> the java page
>> 
>> 
>> import org.apache.tapestry5.annotations.InjectPage;
>> import org.apache.tapestry5.annotations.Persist;
>> 
>> import com.limonn.entities.User;
>> 
>> public class Form {
>>    
>>     private boolean cancel;
>>    
>>     @InjectPage
>>     private Index index;
>>    
>>    
>>      @Persist
>>     private User user;
>>    
>>    
>>      public User getUser() {
>>         return user;
>>     }
>> 
>> 
>>     public void setUser(User user) {
>>         this.user = user;
>>     }
>> 
>>    
>>  
>> void onSelectedFromUpdate() {
>>      cancel = false;
>>    
>>   }    
>>   void onSelectedFromCancel() {
>>      cancel = true;
>>   }
>> 
>>   Object  onSuccess() {
>>      if (cancel) {
>>          
>>          System.out.print(" name was : " + this.user.getName() + " from
>> success");
>>     
>>      } else {
>>          
>>          System.out.print(" name was : " + this.user.getName() + " from
>> cancel");
>>          
>>      } 
>>      return index;
>>   }
>> 
>> ---------------------------------------------------------------------------------------------------
>>                how you get the user.name and user.lastName as properties
>> from User as object from the form ?
>> 
>> Thank 's in advance
>> 
> 
> -- 
> View this message in context: http://www.nabble.com/form-that-create-an-object-tp25414886p25419221.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
>

Re: form that create an object

Posted by limonn <li...@gmail.com>.
 is not working I did try 

<input type="text" t:type="textfield" t:value="user.lastName"
t:id="user.lastName"/>

but 

Failure parsing template context:Form.tml: Component id 'user.name' is not
valid; component ids must be valid Java identifiers: start with a letter,
and consist of letters, numbers and underscores

How you get an object from a form ??

Thanks



limonn wrote:
> 
> I want to have a form that represent an object, so far I have something
> but is not working.
> 
> <form t:type="form" t:id="userForm">
> 
> name : <input type="text" t:type="textfield" t:id="${user.name}"/>
> 
> <br/>
> 
> last name : <input type="text" t:type="textfield"
> t:id="${user.lastname}"/>
> 
> <br/>
> 
> 
> <input t:type="submit" value="Update"   t:id="update" />
> <input t:type="submit" value="Cancel"   t:id="cancel"  />
> 
> </form>
> 
> ----------------------------------------------------------------
> 
> and java 
> 
> (User.java is a regular class with 2 String properties name and lastName
> getters and setters )
> 
> 
> the java page
> 
> 
> import org.apache.tapestry5.annotations.InjectPage;
> import org.apache.tapestry5.annotations.Persist;
> 
> import com.limonn.entities.User;
> 
> public class Form {
>    
>     private boolean cancel;
>    
>     @InjectPage
>     private Index index;
>    
>    
>      @Persist
>     private User user;
>    
>    
>      public User getUser() {
>         return user;
>     }
> 
> 
>     public void setUser(User user) {
>         this.user = user;
>     }
> 
>    
>  
> void onSelectedFromUpdate() {
>      cancel = false;
>    
>   }    
>   void onSelectedFromCancel() {
>      cancel = true;
>   }
> 
>   Object  onSuccess() {
>      if (cancel) {
>          
>          System.out.print(" name was : " + this.user.getName() + " from
> success");
>     
>      } else {
>          
>          System.out.print(" name was : " + this.user.getName() + " from
> cancel");
>          
>      } 
>      return index;
>   }
> 
> ---------------------------------------------------------------------------------------------------
>                how you get the user.name and user.lastName as properties
> from User as object from the form ?
> 
> Thank 's in advance
> 

-- 
View this message in context: http://www.nabble.com/form-that-create-an-object-tp25414886p25419221.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: form that create an object

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Sat, 12 Sep 2009 15:59:45 -0300, limonn <li...@gmail.com> escreveu:

> <input type="text" t:type="textfield" t:value="${user.name}" />

Never use ${} when passing parameters. It should be value="user.name".

-- 
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: form that create an object

Posted by limonn <li...@gmail.com>.
I tried but is not working, it must be a way, or may be not ?

Here is what I did

<form t:type="form" t:id="userForm">

name : <input type="text" t:type="textfield" t:value="${user.name}"
t:id="user.name"/>

<br/>

last name : <input type="text" t:type="textfield" t:value="${user.lastName}"
t:id="user.lastName"/>

<br/>


<input t:type="submit" value="Update"   t:id="update" />
<input t:type="submit" value="Cancel"   t:id="cancel"  />

</form>



limonn wrote:
> 
> I want to have a form that represent an object, so far I have something
> but is not working.
> 
> <form t:type="form" t:id="userForm">
> 
> name : <input type="text" t:type="textfield" t:id="${user.name}"/>
> 
> <br/>
> 
> last name : <input type="text" t:type="textfield"
> t:id="${user.lastname}"/>
> 
> <br/>
> 
> 
> <input t:type="submit" value="Update"   t:id="update" />
> <input t:type="submit" value="Cancel"   t:id="cancel"  />
> 
> </form>
> 
> ----------------------------------------------------------------
> 
> and java 
> 
> (User.java is a regular class with 2 String properties name and lastName
> getters and setters )
> 
> 
> the java page
> 
> 
> import org.apache.tapestry5.annotations.InjectPage;
> import org.apache.tapestry5.annotations.Persist;
> 
> import com.limonn.entities.User;
> 
> public class Form {
>    
>     private boolean cancel;
>    
>     @InjectPage
>     private Index index;
>    
>    
>      @Persist
>     private User user;
>    
>    
>      public User getUser() {
>         return user;
>     }
> 
> 
>     public void setUser(User user) {
>         this.user = user;
>     }
> 
>    
>  
> void onSelectedFromUpdate() {
>      cancel = false;
>    
>   }    
>   void onSelectedFromCancel() {
>      cancel = true;
>   }
> 
>   Object  onSuccess() {
>      if (cancel) {
>          
>          System.out.print(" name was : " + this.user.getName() + " from
> success");
>     
>      } else {
>          
>          System.out.print(" name was : " + this.user.getName() + " from
> cancel");
>          
>      } 
>      return index;
>   }
> 
> ---------------------------------------------------------------------------------------------------
>                how you get the user.name and user.lastName as properties
> from User as object from the form ?
> 
> Thank 's in advance
> 

-- 
View this message in context: http://www.nabble.com/form-that-create-an-object-tp25414886p25417251.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: form that create an object

Posted by Ulrich Stärk <ul...@spielviel.de>.
Read the component reference about the textfield component. You want to use textfield's value attribute.

Uli

On 12.09.2009 16:15 schrieb limonn:
> I want to have a form that represent an object, so far I have something but
> is not working.
> 
> <form t:type="form" t:id="userForm">
> 
> name : <input type="text" t:type="textfield" t:id="${user.name}"/>
> 
> <br/>
> 
> last name : <input type="text" t:type="textfield" t:id="${user.lastname}"/>
> 
> <br/>
> 
> 
> <input t:type="submit" value="Update"   t:id="update" />
> <input t:type="submit" value="Cancel"   t:id="cancel"  />
> 
> </form>
> 
> ----------------------------------------------------------------
> 
> and java 
> 
> (User.java is a regular class with 2 String properties name and lastName
> getters and setters )
> 
> 
> the java page
> 
> 
> import org.apache.tapestry5.annotations.InjectPage;
> import org.apache.tapestry5.annotations.Persist;
> 
> import com.limonn.entities.User;
> 
> public class Form {
>    
>     private boolean cancel;
>    
>     @InjectPage
>     private Index index;
>    
>    
>      @Persist
>     private User user;
>    
>    
>      public User getUser() {
>         return user;
>     }
> 
> 
>     public void setUser(User user) {
>         this.user = user;
>     }
> 
>    
>  
> void onSelectedFromUpdate() {
>      cancel = false;
>    
>   }    
>   void onSelectedFromCancel() {
>      cancel = true;
>   }
> 
>   Object  onSuccess() {
>      if (cancel) {
>          
>          System.out.print(" name was : " + this.user.getName() + " from
> success");
>     
>      } else {
>          
>          System.out.print(" name was : " + this.user.getName() + " from
> cancel");
>          
>      } 
>      return index;
>   }
> 
> ---------------------------------------------------------------------------------------------------
>                how you get the user.name and user.lastName as properties
> from User as object from the form ?
> 
> Thank 's in advance

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