Re: Problems with control tag "if"

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Tuesday, August 3, 2010, 10:46:36 AM, Lars Weber wrote:

>
> Hi,
>
> i am new with struts 2 and freemarker.
> i can't find where the error is.
>
> i have got a list and it works
>
> <@s.iterator value="products" var="product">
> <@s.property value="%{#product.productData.productName}"/>
> </@s.iterator>
>
> but how can i use the if-control tag in the iteration?
>
> doesn't work
> <@s.iterator value="products" var="product">
> <@s.if test='product.productData.productIsOnline = 1'>
>     available
> </@s.if>
> <@s.property value="%{#product.productData.productName}"/>
> </@s.iterator>
>
> also works: 
> <@s.if test='products.size() > 0'>
> </@s.if>
>
> i tested the different data types like boolean, string and integer for
> product.productData.productIsOnline

Since @s.if, @s.iterator etc are Struts-specific tags, I don't really
know. But aren't you supposed to put the expression in the test
attribute inside %{}? (Mind you, %{} is a Struts-thing, FreeMarker
doesn't care about it.)

Anyway... I have never used Struts/WebWorks, so I wouldn't know, but
the whole thing strikes me as wrong. FreeMaker has its own
#if/#elseif/#else tags, also its own iterator tag (#list), and most
importantly, its own expression language. For a good while JSP has
these too (JSTL with the EL). Still you are supposed to mix these
"languages" (FTL and JSP+JSTL) with Struts tags, and with Strut's own
expression language? Sounds like a call for trouble and confusion...
Is this still the best-practice there? /-: (Also, do you have a
working equivalent of the above in JSP?)

> thanks for help,
> lars

-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.