You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Shyamal Mehta <sh...@gmail.com> on 2007/11/16 13:20:21 UTC

Using class constant in if tag

Hi,

I am using the struts if tag and want to use a constant from another
class inside the if test condition.
How can I do it?

The relevant code snippet is:
....
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@page import="com.example.Account"%>
....
<s:if test="status == Account.ACCOUNT_STATUS_ACTIVE" >
    Display message here.
</s:if>


The "status" is a property of my action.

Thanks,
SM

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Using class constant in if tag

Posted by Shyamal Mehta <sh...@gmail.com>.
Thanks Wesley, that works.

On Nov 17, 2007 1:12 PM, Wes Wannemacher <we...@wantii.com> wrote:
> I haven't tried it, but I don't think that OGNL cares about your
> imports. If your constant is static, then try -
> <s:if test="status == @com.example.Account@ACCOUNT_STATUS_ACTIVE">
>
>
> On 11/16/07, Shyamal Mehta <sh...@gmail.com> wrote:
> > Hi,
> >
> > I am using the struts if tag and want to use a constant from another
> > class inside the if test condition.
> > How can I do it?
> >
> > The relevant code snippet is:
> > ....
> > <%@ taglib prefix="s" uri="/struts-tags" %>
> > <%@page import="com.example.Account"%>
> > ....
> > <s:if test="status == Account.ACCOUNT_STATUS_ACTIVE" >
> >     Display message here.
> > </s:if>
> >
> >
> > The "status" is a property of my action.
> >
> > Thanks,
> > SM
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> --
> Wesley Wannemacher
> President, Head Engineer/Consultant
> WanTii, Inc.
> http://www.wantii.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Using class constant in if tag

Posted by Wes Wannemacher <we...@wantii.com>.
I haven't tried it, but I don't think that OGNL cares about your
imports. If your constant is static, then try -
<s:if test="status == @com.example.Account@ACCOUNT_STATUS_ACTIVE">

On 11/16/07, Shyamal Mehta <sh...@gmail.com> wrote:
> Hi,
>
> I am using the struts if tag and want to use a constant from another
> class inside the if test condition.
> How can I do it?
>
> The relevant code snippet is:
> ....
> <%@ taglib prefix="s" uri="/struts-tags" %>
> <%@page import="com.example.Account"%>
> ....
> <s:if test="status == Account.ACCOUNT_STATUS_ACTIVE" >
>     Display message here.
> </s:if>
>
>
> The "status" is a property of my action.
>
> Thanks,
> SM
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Wesley Wannemacher
President, Head Engineer/Consultant
WanTii, Inc.
http://www.wantii.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org