<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %> <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> <%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %> <%-- Tabs Layout . This layout allows to render several tiles in a tabs fashion. @param tabList A list of available tabs. We use MenuItem to carry data (name, body, icon, ...) @param selectedIndex Index of default selected tab @param parameterName Name of parameter carrying selected info in http request. --%> <%-- Use tiles attributes, and declare them as page java variable. These attribute must be passed to the tile. --%> <% String selectedColor="#98ABC7"; String notSelectedColor="#C0C0C0"; int index = 0; // Loop index int selectedIndex = 0; // Check if selected come from request parameter try { selectedIndex = Integer.parseInt(selectedIndexStr); selectedIndex = Integer.parseInt(request.getParameter( parameterName )); } catch( java.lang.NumberFormatException ex ) { // do nothing } // Check selectedIndex bounds if( selectedIndex < 0 || selectedIndex >= tabList.size() ) selectedIndex = 0; String selectedBody = ((org.apache.struts.tiles.beans.MenuItem)tabList.get(selectedIndex)).getLink(); // Selected body %> <%-- Draw tabs --%> <%-- Draw body --%>
  <% // compute href String href = request.getRequestURI() + "?"+parameterName + "=" + index; // Don't add request URI prefix , but let the client compute the original URL // This allows to use a Struts action as page URL, and perform a forward. // Bug reported by Don Peterkofsky //String href = "" + "?"+parameterName + "=" + index; String color = notSelectedColor; if( index == selectedIndex ) { selectedBody = tab.getLink(); color = selectedColor; } // enf if index++; %>
<%=tab.getValue()%>