Mixing TagLibs

Posted on 2006-11-28
Last Modified: 2013-11-24
Using the nested library I'm "3 nests down".   I have a one of my variables is a string that contains multiple words.  

example "apple|pear|bananna"   I need some logic activated by the word "apple".    

<nested:iterate property="nest1" >
       <nested:iterate property="nest2" >
             <nested:iterate property="nest3" >
                     <nested:write property="myNest3String" />
                      prints:  "apple|pear|bananna"
                      here is where I want my logic to trigger on the word "apple" as part of myNest3String.

What is the proper way to do this?    
I am not finding a <c:when><c:if> like statement in the nested library.  
Is there a problem mixing taglibs?
Am I allowed start using a new taglib 3 nests down?    
Or do I have a scope problem?  

Question by:tmonteit
  • 2
LVL 29

Expert Comment

ID: 18035890
There shouldn't be a problem mixing tags.

I don't like the nested tags and always prefer to use the JSTL equivalents but in this case you should be able to use the <logic:equals> struts tag if you can't use the <c:if> tag (I don't know about scope which may be an issue with <c:if>).
 <nested:write property="myNest3String" />
     <logic:equals property="myNest3String" value="apple">Here be apples, lets make cider!</logic equals>

Author Comment

ID: 18039278
I think I've got it.   What's the difference between 'contains' vs. 'equals'?

I noticed you used the 'logic:equals' function.   If myNest3String is "apple juice and orange juice", will your method still return true?

Is there a 'contains' equivalent?
LVL 29

Accepted Solution

bloodredsun earned 400 total points
ID: 18043887
>>What's the difference between 'contains' vs. 'equals'?

There is no 'contains' but there is a 'match'. The match function returns true if the value is a substring of the requested variable, and the equals only returns true if the 2 variables are exactly the same. I don't know why it's not called contains as that what it equates to!

>>If myNest3String is "apple juice and orange juice", will your method still return true?

No as it's not an exact match for the string "apple"

>>Is there a 'contains' equivalent?

Yep. It's match as described above.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question