On 6/5/06, J Gotsch <[EMAIL PROTECTED]> wrote:
Looking at the documentation, it's not clear on how I can use the <logic:match
tag in the following scenario:
<% String menuRole = "ABC"; %>
.....
Now, which of the following three is the correct syntax for the match
comparing?
<logic:match name="<%=menuRole%>" value="ABC">
<logic:match name=<%=menuRole%> value="ABC">
<logic:match name='<%=menuRole%>' value="ABC">
<snip/>
The name attribute is the name of the bean in the specified scope (or
the usual findAttribute() cascading search in all scopes) -- see this
page [1] for details -- thereby the correct snippet per the intent of
the one above would be:
<bean:define id="menuRole" value="ABC"/>
<logic:match name="menuRole" value="ABC">
<%-- Do something --%>
</logic:match>
Or you could do a pageContext.setAttribute() or if in a setup action,
a request.setAttribute().
That being said, its recommended to use JSTL and/or EL wherever
possible. The JSTL equivalent would be:
<c:if test="${fn:contains(menuRole,'ABC')}">
<%-- Do something --%>
</c:if>
-Rahul
[1] http://struts.apache.org/struts-action/struts-taglib/tlddoc/logic/match.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]