seeking 'if' condition with form '($myVar in $myList)'...

Peter Smith <[email protected]>
Newsgroups gmane.comp.java.webmacro.user
Message-ID <[email protected]>
I want to be able to find out if $myVar is in $mylist.
 Is there syntax to handle this w/ WM template
scripting?

  ## Here is my list
  #set $myList = [ "one", "two", "three" ]

  ## Here is the variable I'm looking for
  #set $myVar = "two"

  ## I want to do this
  #if ( $myVar in $myList ) {
    do something...
  }
  #else {
    do something else...
  }

In my particular case, $myList is a java.util.Vector
made up of composite objects - each object has a name,
value, etc.  To keep maintenance simple, I wanted to
avoid doing a multiple-condition 'if' statement like
this:

   #if ( ($myVar==$possibility1)  ||
         ($myVar==$possibility2)  ||
         ($myVar==$possibility3) 
         etc.                  ) ) {
     do something...
   } 
   #else...


To give a fuller picture, my close-to-ideal
pseudo-code looks like this:

  #set $myList = [ "one", "two", "three" ]

  #foreach $compositeObj in $someRuntimeList {

    #if ($compositeObj.name in $myList) {
      do something
    }
    #else {
      do something else...
    }

  }

I've tried to turn around the 'if' condition using
this syntax:

    #if ($myList.contains($compositeObj.name)) {

but I get a 'NoSuchMethodException on a
Ljava.lang.Object'.

Thanks for any pointers.

I'm willing to do some coding if we wanted to add this
to the codebase - only, not sure if I could even
understand enough of the engine (Expression.java
maybe?) to know where to start hacking.



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.