velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jack-tom <agdefen...@yahoo.com>
Subject Re: FormTool doesn't work
Date Thu, 26 Jun 2008 04:35:22 GMT



Christopher Schultz-2 wrote:
> 
> Jake,
> 
> Jake Tom wrote:
>> Hi good day,
>> May I know how to use the velocity FormTool.. 
>> publicclassUserForm extendsActionForm {
>>  
>>     privateUser user;
>>     publicUserForm(){
>>        this.user=newUser();
>>     }
>>     publicUser getUser() {
>>        returnuser;
>>     }
>>     publicvoidsetUser(User user) {
>>        this.user= user;
>>     }
>> …
>> In jsp:
>> <html:form action="/user">
>> <html:text property="user.username"/>
>> <html:text property="user.password"/>
>> <html:submit value="submit"/>
>> </html:form>
>> In velocity how?
>> <INPUT type="text" name="$form.bean.user.username"> doesn’t work!
> 
> This really looks like it should work. Can you try this:
> 
> form = $form
> bean = $form.bean
> user = $form.bean.user
> username = $form.bean.user.username
> 
> and send us the output?
> 
> I have never used the FormTool like this, since Struts puts the form 
> bean into the request for you already. So, if my form "name" (from 
> struts-config.xml) for the action is "userForm", then I would just do 
> this in my page:
> 
> <input type="text" name="$userForm.username" />
> 
> Note that you should always HTML-escape any data coming from the user to 
> avoid XSS vulnerabilities as well as keeping your site looking nice. 
> Also, it seems odd to use the user's username as a form element name. 
> Just a thought.
> 
> -chris
> 

i have tried:
#set ($username = $form.bean.user.username )
#set ($password = $form.bean.user.password )
<FORM method="POST" action="$link.setAction('/user')">
name : <INPUT type="text" name="$username">
password:<INPUT type="password" name="$password">

but i can't get value in my action or actionform

there are two reason why i do so:
1. in action i needn't do:User user=new User();
user.setUsername(form.getUsername()) .....
2. in actionform there are properties:username,password... and some
getter,setter methord,while in User  
    class,it has the same.
nothing is perfect,may be you are right.

Regards, 
jake
-- 
View this message in context: http://www.nabble.com/FormTool-doesn%27t-work-tp18106592p18126379.html
Sent from the Velocity - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Mime
View raw message