Hi there, here is my big problem today. I am using JSTL in some JSPs. SInce this is a struts project, I would like to keep my views totally separated from the Java APIs. For this reason, I need your advice about the most elegant to compare a given object "type" (an int constant) with the possible values using the COSTANT name,
instead of the corresponding int.
The API defines the types of my object as:

public interface ContentType {

   public static final int FOLDER = 1;
   public static final int URL = 2;
}

in my JSP I have (loop over collection of items with getType() returning the type int)

 <c:forEach var="item"  items="${content_list}">
   <c:choose>
    <c:when test="${item.type == 2}">
     <a href="${item.value}"><c:out value="${item.name}"/></a>
    </c:when>
         :

I would like to do something like:

a) <c:when test="${item.type == ContentType.URL}">

This won't work. I could hack it around with a scriptlet and an import at the top of my JSP, but that seems to me like
violating  the separation between View and Control

b) I could do something like this in my action:

   String type_url = "5";
   request.setAttribute("url", type_url);

and then <c:when test="${item.type == url}">

but makes me wonder if having this code in the action really makes sense.

Any ideas?

Thanks

Luca



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to