Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Tiles If/Else

I am wondering if it's possible to have an if/else with Apache Tiles 2 (or JSTL that references a Tiles attribute, that would work to). Basically, I want this:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<div>
    <!-- Some stuff here -->
</div>
<tiles:if condition="showSecondDiv == 'true'">
    <div>
        <!-- Some second stuff here -->
    </div>
</tiles:if>

There is <put-attribute name="showSecondDiv" value="true" type="string" /> in the Tiles XML. The motivation is that I want to reuse this JSP in a number of places, some that want to show both divs, others that only want to show one.

like image 774
Nik Avatar asked Aug 11 '11 14:08

Nik


1 Answers

USING JSTL
example:

     <c:if test="${!empty tilesAdditionalTitle}">
       <fmt:param value="${requestScope[tilesAdditionalTitle]}"  />
     </c:if>
like image 156
Nook Avatar answered Oct 28 '22 18:10

Nook