Re: Array API in velocity

From: Mike Schrag (mschra..dimension.com)
Date: Tue Nov 27 2007 - 14:57:09 EST

  • Next message: Sebastien Sahuc (JIRA): "[OS-JIRA] Created: (WOL-678) Backward and Forward (CMD + [ or CMD + ] ) broken when switching from WOLips components to Java and back"

    I've committed this, but please keep questions on the list ...

    On Nov 27, 2007, at 2:30 PM, Fabian Peters wrote:

    > Hi Mike,
    >
    > I've about finished migrating my templates to the velocity flavour
    > and there's one thing that bugged me. Maybe I'm just being stupid,
    > but to check whether an array contains an object, I found I had to
    > write ugly stuff like this:
    >
    > #* checking whether this entity has localized attributes *#
    > #foreach ($attributeName in $entity.userInfo.localizedAttributes)
    > #foreach ($attribute in $entity.sortedClassAttributes)
    > #if ($attribute.name == $attributeName)
    > #set ($entityHasLocalizedAttributes = true)
    > #end
    > #end
    > #end
    > #if ($entityHasLocalizedAttributes)
    > import com.webobjects.appserver.WOContext;
    > #end
    >
    > Could maybe the ListTool(*) addition help us write this as:
    >
    > #if ($lists.size($entity.userInfo.localizedAttributes) > 0)
    > import com.webobjects.appserver.WOContext;
    > #end
    >
    > If you think this is possible I'll readily log another feature
    > request. ;-)
    >
    > cheers, Fabian
    >
    > (*) <http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/ListTool.html
    > >



    This archive was generated by hypermail 2.0.0 : Tue Nov 27 2007 - 14:58:24 EST