You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by he...@teradyne.com on 2003/07/17 17:55:07 UTC
a tag to check an "enum"?
What approaches are there to using jsp tags checking java "enums". And NOT
using scriplets..
So I have some kind of state which I want to check, based on enums. Am I
forced to write my own custom tag? OR are there ways with existing ones.
By enums, I mean class, private constructor, public static final fields,
etc.. Described many places in java articles.
Example class
public class Power implements Serializable {
public static final Power OFF = new Power(0);
public static final Power ON = new Power(1);
private int _value;
private Power(int value) {
_value= value;
}
..
..
readResolve...
..
..
}
So assuming a page scope bean has an accessor to a Power instance. I want
to check if the power is on or off and print different text out.
What are the approaches commonly used?
thanks
Henrik Bentel
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: a tag to check an "enum"?
Posted by Mike Jasnowski <mj...@bea.com>.
What about something like:
<logic:equal property="value" value="0">
Print some text
</logic:equal>
or JSTL
<c:choose>
<c:when test="${Power.value == Power.OFF}">
Power off
</c:when>
<c:otherwise>
Power on
</c:otherwise>
</c:choose>
-----Original Message-----
From: henrik.bentel@teradyne.com [mailto:henrik.bentel@teradyne.com]
Sent: Thursday, July 17, 2003 11:55 AM
To: struts-user@jakarta.apache.org
Subject: a tag to check an "enum"?
What approaches are there to using jsp tags checking java "enums". And NOT
using scriplets..
So I have some kind of state which I want to check, based on enums. Am I
forced to write my own custom tag? OR are there ways with existing ones.
By enums, I mean class, private constructor, public static final fields,
etc.. Described many places in java articles.
Example class
public class Power implements Serializable {
public static final Power OFF = new Power(0);
public static final Power ON = new Power(1);
private int _value;
private Power(int value) {
_value= value;
}
..
..
readResolve...
..
..
}
So assuming a page scope bean has an accessor to a Power instance. I want
to check if the power is on or off and print different text out.
What are the approaches commonly used?
thanks
Henrik Bentel
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org