You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Bart Conrath <ba...@conrath.com> on 2001/02/21 07:07:39 UTC

How to get pre-filled forms when properties are objects

Hello,
  I've tried unsuccessfully to get Struts to work on the form.  I'm trying
to build.  I'm probably missing something very fundamental with Struts.

Any help would be appreciated.  Here is the setup.

I have a form bean called EditForm.  I'd like to get a user-editable form
but with the values pre-filled.  So what I do is carry over an attribute
from the Action class that precedes the form.  It's basically a simple
search, which works fine, that returns the results of the search.  But
instead of static text, the results are presented in a text boxes or
selects.  These fields are inside the EditForm which includes an update
button.  The problem I am having occurs in that the bean that is returned
from the search has properties that are objects.  For these properties, I
would like the user to view and then to update the identity field of that
property.  I hope this is clear.  If anybody is willing to help me, I can
provide more information.  Or is anybody has done something similar and can
show me the light or some sample code, that would be great.  I'm at an
impasse and am not sure where to go from here.
Thanks.


Re: How to get pre-filled forms when properties are objects

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Bart Conrath wrote:

> Hello,
>   I've tried unsuccessfully to get Struts to work on the form.  I'm trying
> to build.  I'm probably missing something very fundamental with Struts.
>
> Any help would be appreciated.  Here is the setup.
>
> I have a form bean called EditForm.  I'd like to get a user-editable form
> but with the values pre-filled.  So what I do is carry over an attribute
> from the Action class that precedes the form.  It's basically a simple
> search, which works fine, that returns the results of the search.  But
> instead of static text, the results are presented in a text boxes or
> selects.  These fields are inside the EditForm which includes an update
> button.  The problem I am having occurs in that the bean that is returned
> from the search has properties that are objects.  For these properties, I
> would like the user to view and then to update the identity field of that
> property.  I hope this is clear.  If anybody is willing to help me, I can
> provide more information.  Or is anybody has done something similar and can
> show me the light or some sample code, that would be great.  I'm at an
> impasse and am not sure where to go from here.
> Thanks.

It is not real clear what you are trying to accomplish (a simple use case would
be helpful), but here is the strategy I use for pre-filling input forms --
create an Action that prefills the form for me.

In the Struts example application, for instance, note that the link to "edit
your profile" on the main menu page goes to "editRegistration.do", which is an
Action.  The action prepopulates the RegistrationForm form bean with the user's
current profile information, so that they can change it.

In a similar fashion, the links to create, edit, or delete subscriptions all go
to an action (editSubscription.do) that prepopulates the SubscriptionForm bean
before it gets displayed by the "subscription.jsp" page.

Craig McClanahan