You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by samsongbest <sa...@gmail.com> on 2012/06/03 16:43:40 UTC
Can I use in
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
Re: Can I use in
Posted by Dave Newton <da...@gmail.com>.
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.
Dave
On Sun, Jun 3, 2012 at 10:43 AM, samsongbest <sa...@gmail.com> 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
RE: [struts-user] Can I use in
Posted by Jason Pyeron <jp...@pdinc.us>.
> -----Original Message-----
> From: samsongbest
> Sent: Sunday, June 03, 2012 10:44
> To: user
> Subject: [struts-user] Can I use <s:if> in <s:textfield>
>
> 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">.
Since the tag belongs to a taglib, you cannot. But you can set a var using
conditional logic, and then using the var as an expression in the <s:textfield
cssClass="#var" />
See:
http://struts.apache.org/2.x/docs/set.html
http://struts.apache.org/2.x/docs/if.html
-Jason
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- -
- Jason Pyeron PD Inc. http://www.pdinc.us -
- Principal Consultant 10 West 24th Street #100 -
- +1 (443) 269-1555 x333 Baltimore, Maryland 21218 -
- -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This message is copyright PD Inc, subject to license 20080407P00.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org