I am writing a simple tag which contains 4 attributes like so:
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ attribute name="menuName" description="Name of Major Menu" required="true" %>
<%@ attribute name="menuSize" description="Number of Items In Menu" required="true" type="java.lang.Integer" %>
<%@ attribute name="menuImage" description="Icon for Image" required="true" %>
<%@ attribute name="menuNumber" description="Order of Positioning" required="true" %>
There is a point within a Struts 2 tag that I need to make reference to one of these attributes like so:
<s:set name="it" value="%{#application['tools'][${menuName}]}" />
So you see I am doing a lookup in the OGNL expression based upon what the menu name which was passed in. From all the examples I see, EL is the common way of referencing the attribute menuName, but in Struts 2.x EL is disabled for security reasons.
Is there a way to reference the attribute I need to reference. I really do not want to consider any solution which involves me going to previous versions of jstl or struts.
<s:set name="menuName" value="%{#attr['menuName']}" />
<s:set name="it" value="%{#application['tools'][#menuName]}" />
Never knew about the #attr before, how neat