Howdy All,I would create a pull tool to provide the default values and error messages (much less cumbersome than David's suggestion) and then a velocity macro that uses the pull tool to produce the final result.
I realize this is more a velocity question, but the velocity email list is shared with the jakarta commons list and doesn't seem to have much velocity traffic on it.
What I'm trying to do is create a velocity macro that can define an input field using a fixed name for the field and have that macro have provisions for default values for the field based on the fields fixed name. For example, I'd love to do something like
#macro ( myInput $fieldName )
<INPUT TYPE="TEXT" NAME="FLD_$fieldName" VALUE="$!{VALUE_${fieldName}}">
#end
so
#myInput ( "UserName" )
becomes
<INPUT TYPE="TEXT" NAME="FLD_UserName" VALUE="Gerry">
Assuming my Context has a symbol called VALUE_UserName in it set to the string "Gerry" (i.e. context.put("VALUE_UserName", "Gerry")).
In short, the ability to have an interpreted reference/variable name.
It would also let me do things like having macros that knew how to display errors attached to fields automatically. Consider:
#macro ( myInput $fieldName )
<INPUT TYPE="TEXT" NAME="FLD_$fieldName" VALUE="$!{VALUE_${fieldName}}">
#if ( ${ERROR_${fieldName}} )
<FONT COLOR="red">* ${ERROR_${fieldName}}</FONT>
#end
#end
This gives my verification routines a great deal of flexibility and allows very generic forms processing modules.
Any thoughts (on how to do this or if you think I'm bonkers, that is :-)?
Gerry
Scott
-- Scott Eade Backstage Technologies Pty. Ltd. http://www.backstagetech.com.au
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
