Assign the bean value to a variable defined in template
Samuel Viana <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Hi
I'm new to FreeMarker and I am trying to capture the content of a bean to a
variable defined in the template. The purpose of this is to give the designers
the opportunity to easily create the templates providing only a macro that calls
that variable and renders a table row with the bean's contents, contents that
are holded in a variable that is human-readable, the problem is that the bean's
is passed through an attribute that comes from a Struts action - truthly
speaking, the bean is stored in an HashMap that is acceded in this way:
<#assign lavazza2200>content.getProduct("106738243-20000212")</#assign>
"content" is the map that cames from the Structs Action class, and in
here the argument of the getProduct method is the key to fetch
the bean, that should be stored in the variable named "lavazza20".
This way, the web designers only need to do:
<@table_row prod="lavazza2200"/>
in order to a draw a table row with the bean's contents.
The problem is that what the variable "lavazza2200" really holds is not the bean
itself, but rather the output of its toString method. Anyway, I was forced to
use the syntax
<#assign [variablename]contents_for_the_variable></#assign>
since this syntax is not allowed:
<#assign lavazza2200 = ${content.getProduct("106738243-20000212")} />
Can you suggest me a way allowed by Freemarker to store the bean inside a
variable that its defined in the template ? Remember that what the Struts Action
is sending to the template is a Map, that contains the bean that I want to store
in a certain variable.
Best regards,
Samuel
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/