Hello!
If i want to fill a form with data (from, say a database) before showing
it to the user: Can this be done in reset() method of the form, or should
it be in the perform() method of the action class?
I think that doing it in the reset() method produces the cleanest code.
This can be done in quite a dynamic way too, since the reset method has
access to the http request and the mapping. It can use these to get info
on what (if any) item to load from the database.
Short example:
<--------------------------->
I have an action called editOrder and a form called orderForm.
In the reset method of the form:
reset(mapping,request) {
// check mapping, the form might be used by other actions
// that don't want our little featue
if (mapping.getType.equals("editOrder") {
int orderId = request.getInt("orderId");
OrderData order = db.loadOrder(orderId);
this.orderName = order.getName();
this.orderSize = order.getSize();
// .. and so on
}
}
<--------------------------->
Any suggestions or thoughts around this way of doing things? Looks nice to
me,
but I'd sure like to know if there is something nasty that I've missed here.
Regards,
Mattias Norlander
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>