struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <>
Subject Re: Can I use <s:if> in <s:textfield>
Date Sun, 03 Jun 2012 15:06:56 GMT
Of course not; you cannot nest one JSP tag inside another JSP tag. In the
*body content* of a tag, sure.

HTML elements are not JSP tags, which is why it works in a normal HTML
element. (Side note, make sure you're aware of what things in a JSP page
are, where they come from, where they're executed/evaluated, etc.)

You can use <s:set> etc. to create new variables which you can refer to
inside S2 tags (untested, but relatively close, maybe?):

<s:set var="foo" value="'a-style'"/>
<s:textfield cssClass="%{#foo}"/>

You can also use OGNL's ternary expression, but IMO only do that if it's
still readable and not a million characters long.


On Sun, Jun 3, 2012 at 10:43 AM, samsongbest <> wrote:

> Can I use <s:if> in <s:textfield> to control using different cssClass?
> Always failed when I tried.
> But it works in <input type="text">.
> Sam

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message