"Henning P. Schmiedehausen" wrote:
>
> Hi,
>
> in some of my forms, I use the following approach in the .vm:
>
> --- cut ---
> #if($!bo)
> #set ($frm = $intake.inputBO.mapTo($bo))
> $frm.Mode.
> #else
> #set ($frm = $intake.inputBO.default )
> #end
>
> <FORM NAME="entryForm" METHOD="POST" ACTION="action">
> #set ($_key = $frm.get("field"))
> <INPUT TYPE="text" VALUE="$!key" NAME="$_key.Key">
> #set ($_key = $frm.get("field2"))
> <INPUT TYPE="text" VALUE="$!key" NAME="$_key.Key">
> $intake.declareGroups()
> </FORM>
> --- cut ---
not sure where $key is defined, is this a mistake and it should be
VALUE="$!_key"
You could do something like:
#if ( $_key.toString().length() == 0 )
#set ( $value = "default value" )
#else
#set ( $value = $_key.toString() )
#end
<input value="$value" ...
I am not opposed to adding default values to intake if you wish to add
it, though it does not fit with my current usage. Another possibility
is to always have the $bo be not null and have it return default values
if it is new and unmodified.
john mcnally
>
> This works fine with all fields empty if no Business Object is
> supplied ($bo == null).
>
> Now the following question came up: How do I do Default Values?
> e.g. I want the "field2" preset to value "xxxxx" for a new entry.
>
> As far as I can see, there is no way to define default values in the
> intake XML file. Do I really have to do it by build a class doing:
>
> public class foo extends VelocityScreen
> {
> public void doBuildTemplate(RunData r, Context c)
> {
> BusinessObject bo = (BusinessObject)ctx.get("bo");
> if(bo == null)
> {
> bo = new BusinessObject();
> bo.setField2("xxxxxx");
> }
> }
> }
>
> or is there a way to do this automatically using intake / velocity? Am
> I plain overseeing something?
>
> Anyone interested in me implementing a "default value" field for use
> in the intake.xml configuration file?
>
> (Using TDK 2.1 with Turbine 2.2beta<something>).
>
> Regards
> Henning
>
> --
> Dipl.-Inf. (Univ.) Henning P. Schmiedehausen -- Geschaeftsfuehrer
> INTERMETA - Gesellschaft fuer Mehrwertdienste mbH [EMAIL PROTECTED]
>
> Am Schwabachgrund 22 Fon.: 09131 / 50654-0 [EMAIL PROTECTED]
> D-91054 Buckenhof Fax.: 09131 / 50654-20
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]