When populate drop down list (struts)

Discussions

General J2EE: When populate drop down list (struts)

  1. When populate drop down list (struts) (4 messages)

    Hi,
    Excuse me for my simple question, but I'm rookie:(
    I have a simple form and one of the properties is set via drop down list. The list is populated with data from DB. Where should I put the code that populates the list with DB data? Currently I put it into reset() method of the form, but I'm not sure if it is the best choice.

    jarek
  2. Hi,

    According to the ActionForm API :

    "This method is not the appropriate place to initialize form value for an "update" type page (this should be done in a setup Action). You mainly need to worry about setting checkbox values to false; most of the time you can leave this method unimplemented."

    Ideally you would have got the values from the DB in the Action class.
    So why don't you set the property in the Action class itself as the API recommends.

    Regards,
    Srini
  3. You can create a Collection property on your ActionForm that holds these values. Populate it from your Action. Use Struts tags to pull the values in to your page.
  4. Thanks for the advice! I've already corrected my stupid error :) Sorry for this question, but I'm very new to struts and j2ee:(

    Best wishes,
    jarek
  5. Please help[ Go to top ]

    Can you please tell me how to populate a drop-down menu box in struts retreiving data from database??