Leonardo Uribe schrieb:
> Hi
>
> I have a design question. I'm working on generate component tag
> classes using velocity.
>
> In this part it is common to found some situations when you need
> utility methods. There are several methods
> to do this:
>
> 1) Implementing this methods on a java class, and use the following
> code using a macro file on inside the template:
>
> ## [[[[[ Setting Utility Classes to use ]]]]]
> ##
> #set($utils =
> $classes.forName("org.apache.commons.lang.StringUtils").newInstance())
>
> In this case, we can copy
> org.apache.myfaces.buildtools.maven2.plugin.faces.util.Util form
> myfaces-faces-plugin and use it
> inside the templates. like this
>
> $utils.lowerCase($field.getAttributeValue("name"))
>
> 2) Use a file to create velocity macros and implement this here.
> Inside we need to use StringUtils like in (1), but from the point of
> view of the template designer, He/she doesn't see this.
>
> 3) Create methods on each Model and XXXMeta. Sometimes this is
> unavoidable (like getting the properties from a component) and is more
> clean. For example:
>
> package ${component.tagPackage};
>
> public class ${component.tagName}{
>
> #foreach( $property in ${component.propertyList} )
>              //getter and setter methods
> #end
> }
>
> This two methods (getTagPackage and getTagName and derived properties
> of tagClass).
>
> What option could be better? If no suggestions, I will go for option 1
> and 3.

+1

Reply via email to