You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by J Gotsch <jo...@yahoo.com> on 2006/06/05 21:29:01 UTC

Struts Tag -
  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"> 

 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Struts Tag - Posted by Rahul Akolkar <ra...@gmail.com>.
On 6/5/06, J Gotsch <jo...@yahoo.com> 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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org