You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Choon Chern, Lim" <me...@rocketmail.com> on 2006/08/03 05:00:13 UTC
Couldn't retrieve value from Struts bean
Hello,
I'm currently using Struts and Velocity, where the vm
file gets the Struts ActionForm to populate the form
fields.
I have a macro as below:-
#macro( datetime $var )
<input type="text" name="${var}Date"
value="$form.bean.${var}Date" />
#end
I made a call in my HTML as below:-
#datetime(visit)
The associated form bean for this page contains a
String field called "visitDate".
When the macro resolves, I'm seeing this:-
<input type="text" name="visitDate"
value="org.meteoric.FrmVisit@32f76519.visitDate" />
It doesn't resolve the value part.
So, I tried hardcoding it this way to test:-
<input type="text" name="visitDate"
value="$form.bean.visitDate" />
... and it retrieves the date from the bean and
display properly in the value property.
How do I fix my macro to achieve my desired result?
Thanks.
Mike
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Couldn't retrieve value from Struts bean
Posted by Will Glass-Husain <wg...@forio.com>.
You can't construct a reference like that. Try
#macro( datetime $var $ref)
<input type="text" name="$var" value="$ref" />
#end
with a call
#datetime("visitDate" $form.bean.visitDate )
WILL
On 8/2/06, Choon Chern, Lim <me...@rocketmail.com> wrote:
>
> Hello,
>
> I'm currently using Struts and Velocity, where the vm
> file gets the Struts ActionForm to populate the form
> fields.
>
> I have a macro as below:-
>
> #macro( datetime $var )
> <input type="text" name="${var}Date"
> value="$form.bean.${var}Date" />
> #end
>
> I made a call in my HTML as below:-
>
> #datetime(visit)
>
> The associated form bean for this page contains a
> String field called "visitDate".
>
> When the macro resolves, I'm seeing this:-
>
> <input type="text" name="visitDate"
> value="org.meteoric.FrmVisit@32f76519.visitDate" />
>
> It doesn't resolve the value part.
>
> So, I tried hardcoding it this way to test:-
>
> <input type="text" name="visitDate"
> value="$form.bean.visitDate" />
>
> ... and it retrieves the date from the bean and
> display properly in the value property.
>
> How do I fix my macro to achieve my desired result?
>
> Thanks.
>
> Mike
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
--
Forio Business Simulations
Will Glass-Husain
wglass@forio.com
www.forio.com
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org