3

To preface this, I do not work with Java or Struts, but I understand what is going on in the code. When it comes to writing the code, I am clueless. I am working with KonaKart, and they use struts tiles to display layouts.

Here is the jsp snippet:

<div class="siderBox noMargin">
    <div class="siderBoxTop"></div>
    <div class="siderBoxContent">
        <tiles:insert attribute="leftTile1" />
    </div>
    <div class="siderBoxBottom"></div>
 </div>

Depending on the current page, leftTile1 may have a value of Empty.jsp which is just an empty page (this is leftTile5 and leftTile6 for example):

<put name="leftTile5" value="/WEB-INF/jsp/InformationTile.jsp"/>
<put name="leftTile6" value="/WEB-INF/jsp/Empty.jsp"/>

If the tile has an empty page, then the box still appears and I am left with all these blank boxes. Is there any way to get the attribute value and not display the tile (ie. if(leftTile1.attribute!="/WEB-INF/jsp/Empty.jsp"){ //show the content; })?

Worst case scenario, I can just go through all 30 jsp files and wrap the content with the header and footer for the tile.

Screenshot of the current output and what I want to get rid of: Blank tiles

0

2 Answers 2

7

Not tested, but you could probably define the attribute as an empty string rather than /WEB-INF/jsp/Empty.jsp if nothing must be displayed, and use the following code in your layout:

<tiles:useAttribute name="leftTile1" id="leftTile1"/>
<c:if test="${!empty leftTile1}">
    <div class="siderBoxContent">
        <tiles:insert attribute="leftTile1" />
    </div>
</c:if>
1
  • That sounds good, I will try it tomorrow at work... in the meantime, I used jQuery to wrap the included portions with my tags and it does the trick perfectly. Dec 28, 2011 at 0:13
2

Ultimately this ended up working:

<tiles:importAttribute name="leftTile1" scope="request" />
<logic:notEqual name="leftTile1" value="/WEB-INF/jsp/Empty.jsp">
    <div class="siderBox noMargin">
         <div class="siderBoxTop"></div>
         <div class="siderBoxContent">
              <tiles:insert attribute="leftTile1" />
         </div>
         <div class="siderBoxBottom"></div>
     </div>
</logic:notEqual>

Thanks for your help JB, it got me pointed in the right direction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.