You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marc Zampetti <za...@aol.net> on 2002/07/19 22:11:33 UTC

and empty forms

All,
I'm new to Struts, and I am having a problem understanding how to design 
a particular form that I need. Basically, I need to have several lines 
of fields, each line having four fields. Three of the fields are 
drop-down lists that get populated from a JavaBean in the session. The 
other field is a simple text field. I need to have say 14 lines of these 
fields. The user doesn't have to input information for all of these 
fields, but the ones they do enter, I need to be able to show in "edit" 
mode, and thus populate with a <logic:iterate> tag.
I have the ActionForm designed that will take all of the data, using an 
String[] for each column, and I have a page that works for entering the 
information. What I don't understand how to do is be able to 
design/designate the form so then on error, or in edit mode, each of the 
lines gets filled with the correct information from the ActionForm, and 
the rest of the form gets filled with the defaults.
Anyone have any ideas?

-- 

Marc Zampetti
AOL PACT Ops
(703) 265-5278



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: and empty forms

Posted by Rob Leland <rl...@apache.org>.
 > information. What I don't understand how to do is be able to
 > design/designate the form so then on error, or in edit mode, each of
 > lines gets filled with the correct information from the ActionForm,
 > the rest of the form gets filled with the defaults.
 > Anyone have any ideas?

I'll briefly answer this.
The mailing lists, lists many others with much more detailed answers to 
this very question. Towards the bottom of the struts main
page
          http://jakarta.apache.org/struts/
lists



When the user posts the only fields that will be filled in are the
user response fields. If the ActionForm has a request scope 
(recommended), then only the user input fields will be returned.
The dropdown/combobox must be filled in every time before forwarding to
an error page or edit page.
I usually create a repopulate() method in the action, it fills in the
dropdown values and defaults.

The other alternative is to use a session scope form, then the dropdown
box values only need to be filled in once. With 1000 users this can 
consume considerable resources.

Then for each dropdown you would have code similar to:

<html:form action="/savePublish" enctype="multipart/form-data">


   <html:select property="profile">
      <html:options property="profileList"/>
   </html:select>

</html:form>

Look at the  docs for html:options java docs for other tag
attributes besides "property", like I maybe "value".


Where profileList is some collection or array in your form object.
     /**
      * The List of profiles
      */
     private ArrayList profileList=null;




Marc Zampetti wrote:

> All,
> I'm new to Struts, and I am having a problem understanding how to design 
> a particular form that I need. Basically, I need to have several lines 
> of fields, each line having four fields. Three of the fields are 
> drop-down lists that get populated from a JavaBean in the session. The 
> other field is a simple text field. I need to have say 14 lines of these 
> fields. The user doesn't have to input information for all of these 
> fields, but the ones they do enter, I need to be able to show in "edit" 
> mode, and thus populate with a <logic:iterate> tag.
> I have the ActionForm designed that will take all of the data, using an 
> String[] for each column, and I have a page that works for entering the 
> information. What I don't understand how to do is be able to 
> design/designate the form so then on error, or in edit mode, each of the 
> lines gets filled with the correct information from the ActionForm, and 
> the rest of the form gets filled with the defaults.
> Anyone have any ideas?
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>