Switch housing with display tag

I want to display different data in the Display Tag column according to what I get with Session.

How to integrate the switch enclosure with the <display:column> ? I want to display AAA if the unit value that I get from the session is 1, etc.

Here is what I want to do.

 switch(List.unit){ case 1: unit = "AAA"; break; case 2: unit = "BBB"; break; case 3: unit = "CCC"; break; default: unit = "undefined"; break; } 

Thanks.

+6
source share
1 answer

You do this with displaytag in the same way as without it. Just calculate the desired block in the servlet / action manager for your JSP and store this device in some bean in the request. Then select this bean in JSP:

 <display:column>${theBeanStoredInTheRequest.unit}</display:column> 

Or compute it in the JSP itself using JSTL, but it is more verbose:

 <display:column> <c:choose> <c:when test="${sessionScope.unit == 1}">AAA</c:when> <c:when test="${sessionScope.unit == 2}">BBB</c:when> <c:when test="${sessionScope.unit == 3}">CCC</c:when> <c:otherwise>undefined</c:otherwise> </c:choose> </display:column> 
+18
source

Source: https://habr.com/ru/post/898343/


All Articles