velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <>
Subject Re: Retrieve form elements from a velocity page
Date Wed, 29 Oct 2003 17:28:31 GMT wrote:
> I have recently started learning velocity. I am now trying to use it as 
the view in my Struts application. But I am facing the following problem: 
"retrieve data displayed in my form elements."
> In my velocity page I write:
> ============================
> <input name="siret" type="text" id="siret" 
value="$!creationAdminOfForm.siret" size="17" maxlength="17" 
> ============================
> The form is well displayed but when I fill and submit, I have a surprising 
result; nothing displayed!!! I try with other forms elements (checkBox, 
select); the result is still the same.
> Please tell me WHAT I AM MISSING HERE? Please tell me where I can find web 
page examples formatted with velocity, containing form elements such as 
checkBoxes, select, textField, etc... 

To my casual glance, what you have seems workable.   It may be that your 
actual problem is generating the next page rather than collecting the data.  

In struts-config:

In my velocity page:
				<FORM method="POST" action="$link.setAction('LoginResult')">
					<strong>$msg.get("label.username"):</strong><BR /="">
					<INPUT type="text" name="username" value="$!{loginForm.username}" 
size="10" maxlength="32" class="login" id="userID" /><BR /="">
					<strong>$msg.get("label.password"):</strong><BR /="">
					<INPUT type="password" name="password" value="$!{loginForm.password}" 
size="10" maxlength="32" class="login" /><BR /="">

In my Action, to read the data afterward:
		String userName = (String)((DynaValidatorForm)form).get("username");
		String password = (String)((DynaValidatorForm)form).get("password");

You can throw the following on your velocity page to see what's in the 
request context and verify that creationAdminOfForm exists:

<!-- request dump:
#foreach( $attribute in $request.attributeNames)

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message