Hi Vjeran,
What do you mean by elegant?
An if statement will work, but certainly not elegant.
---
#if ("$!data.Parameters.Url" == "")
#set ($url = "http://")
#else
#set ($url = "$data.Parameters.Url")
#end
<input type="text" name="url" value="$url">
---
Alternately, you can stuff it into the context from the underlying java
class:
--- blah.java ---
package com.whatever;
// Velocity Stuff
import org.apache.velocity.context.Context;
import org.apache.commons.lang.StringUtils;
// Turbine Stuff
import org.apache.turbine.util.RunData;
import org.apache.turbine.modules.screens.VelocityScreen;
public class blah extends VelocityScreen {
public void doBuildTemplate(RunData data, Context context) {
// the context object has already been setup for you!
context.put("url",
StringUtils.defaultString(data.getParameters().get("Url"), "http://"));
}
}
--- blah.vm ---
<input type="text" name="url" value="$url">
---
Not elegant either unless you are already using an underlying class and can
just add the one line.
Good luck,
David
-----Original Message-----
From: Vjeran Marcinko [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 20, 2004 11:55 PM
To: [EMAIL PROTECTED]
Subject: Initial form field value
Hi folks.
I'm not using Intake to handle form fields, because I have some requirements
that it doesn't fit into. Nevertheless, I use standard way of handling form
fields :
<input type="text" name="url" value="$data.parameters.url">
I'm using value="$data.parameters.url", thus field value would be populated
with previous value in case of reviewing form page due to validation
exception. Everything works fine except I dunno how to set elegantly initial
field value ? In case above, I would like to be 'http://' value since it is
URL field. Can somebody point me the way ?
Regards,
Vjeran
---------------------------------------------------------------------
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]