Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Struts Tiles - Get attributes

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

like image 917
Tim Withers Avatar asked Feb 01 '26 23:02

Tim Withers


1 Answers

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>
like image 142
JB Nizet Avatar answered Feb 04 '26 16:02

JB Nizet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!