Yeh alright mate. Keep ya hair on and enough with the shouting already!

Since the forms are only instantiated when a request for that mapping comes
in its gonna be kinda hard to prepopulate values on them cos they dont exist
yet. Indeed unless you are using session mapped forms (such as for a
multipage wizard or such like) the form is only going to exist for the scope
of the request.

Now Im assuming that you need to read these default values from somewhere
(which must be why you dont just slap em into the form constructors
directly). Since they dont change while the app is running (another
assumption your post didnt bother clarifying) your best bet would be to read
them into some kind of config objects (perhaps even a 'prototype' instance
of the forms in question) and store these in the servlet context. Implement
a struts plugin to do this at startup time.

You could initialise the values in the form instance from these config
objects in the reset method. Dont forget to do this only on the first reset
(or you will overwite input).

I reckon you would be best off doing as you were advised and copying the
defaults into the form in an action though rather than overloading the reset
method for this purpose.

As for the lists of selectable choices in things such as drop downs - that
would best be left as shared beans in servlet scope (like Nathan says in his
reply to your post) - you would only want to copy values into the form
instance for defaults for stuff, as you can have your tags access the shared
beans directly for such tasks as rendering options in selects...


-----Original Message-----
From: Curtney Jacobs [mailto:[EMAIL PROTECTED]
Sent: Monday, 11 August 2003 13:46
To: Struts Users Mailing List
Subject: UPON APPLICATION STARTUP!!!!!!!!!!!!!!!!


Greetings!

I would like to load default values in my forms upon application startup. Is
this possible with STRUTS? Seriously, is this possible with STRUTS? If not,
I
will have to look some where else for this.

Many of my forms have drop down list that enables the user to choose the
appropriate values. It would be nice that UPON APPLICATION STARTUP forms
that
need default values are automatically populated with said values.

I am aware that I can call an action that can prepopulate my forms with
those
values. However, it seems tedious to always call an action to populate a
form
with default values.

Has anyone done this before, if so, I would greatly appreciate some
assistance.


This is like the upteen post concerning this. I find it hard that no one
else
needs this or has done this.

Regards,

Curtney

---------------------------------------------------------------------
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]

Reply via email to