It seems that what you want to do is typical. I suggest you to take a
different approach, a model-based approach.

Consider this: you want to create or modify an _object_, not just some
form fields. So, your form should pull the data from an object and
show it. It should not matter for the form, is this object new or
existing. The form just shows what is in it, period.

This is how I do it: I have "editItem" action, which shows object by
ID. I also have a "current" object, that is, the one I work with at
this moment. The "current" object is stored in session. "editItem"
action receives object ID in the request, and looks up for the object
to display. It checks first, is "current" object the one that needed.
If not, if loads object from the database and makes it "current"
(previous "current" object is lost). Then it shows its content. That's
it.

How do I create an object: I have a separate "createItem" action,
which creates a new empty object, assigns object ID to it, and sets it
as "current" object in the session. Then it redirects to "editItem",
which shows new empty object.

Simple. Notice, that "editItem" does not care where it was called
from. It does not have any preconditions. It recieves object ID, and
shows object content. Bulletproof. I do not need to prepopulate
anything, I just show what is in the object.

If you like this idea, check out these links:
  http://www.theserverside.com/articles/article.tss?l=RedirectAfterPost2
  http://wiki.apache.org/struts/StrutsCatalogInputOutputSeparation  

Michael.

On 5/8/05, David Johnson <[EMAIL PROTECTED]> wrote:
> Right. What I want is to pre-populate text fields if the user id "editing"
> or set it to "" if the user is creating a new thing. 
>   
> I think what I'll settle on is making the "portfolioName" request attribute
> a session attribute instead, then in the Save() methos, execute a
> myForm.reset() 
>   
> Is that fairly typical? Is there a better way to achive my goal of
> prepopulating fields that exist? I guess I assumed that they'd be populated
> but be linked to the form bean assigned to the form. 
>   
> Sigh. 
>   
> I feel like there's just a small bit of understanding I'l lacking here....

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to