On Wed, Dec 23, 2009 at 4:56 AM, Vitor E. Silva Souza
<[email protected]> wrote:
> Hello all,
>
> I'm creating a UI Component with Struts 2.1.8.1. The FreeMarker variable
> parameters seems to be made available as String and not as Hash as I expected
> (and according to [1]).
>
> [1] = http://www.vitarara.org/cms/struts_2_cookbook/creating_a_ui_component
>
> In the web page, I have something like this:
>
> <s:component template="book-list.ftl" >
> <s:param name="deletecolumn" value="true" />
> </s:component>
>
I can't guarantee that it will work, but try changing the s:param to this -
<s:param name="deletecolumn" value="%{true}" />
Notice the lack of quotes around 'true' and the forcing of OGNL with
%{... If that doesn't work, you may be stuck with a string.
-Wes
> And in the file template/xhtml/book-list.ftl (in the source folder) I have a
> component that shows a table with the list of books in the database:
>
> <#if books?size == 0>
> <p><@s.text name="noBooks" /></p>
> <#else>
> <table align="center" size="90%">
> <tr>
> <th><@s.text name="name" /></th>
> <th><@s.text name="authors" /></th>
>
> <#if parameters?contains("deletecolumn=true")>
> <th> </th>
> </#if>
> </tr>
> <#list books as book>
> <tr>
> <td>${book.name}</td>
> <td>${book.authors}</td>
>
> <#if parameters?contains("deletecolumn=true")>
> <td>[... delete button ...]</td>
> </#if>
>
> </tr>
> </#list>
> </table>
> </#if>
>
>
> I expected to have to use it like this, as a hash (or something like it):
>
> <#if parameters.deletecolumn == "true">
>
> And instead, the only way it works is as above, as a string:
>
> <#if parameters?contains("deletecolumn=true")>
>
> If I use it as hash, it gives me ArrayIndexOutOfBoundsException: -1.
>
> Any thoughts?
>
> Thanks in advance,
>
> Vitor Souza
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
--
Wes Wannemacher
Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]