Mixing TagLibs

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.
             </nested:iterate>
       </nested:iterate>
</nested:iterate>



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?  

example?
tmonteitAsked:
Who is Participating?
 
bloodredsunConnect With a Mentor Commented:
>>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.
0
 
bloodredsunCommented:
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>
  </nested:iterate>
...
..
.
0
 
tmonteitAuthor Commented:
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?
0
All Courses

From novice to tech pro — start learning today.