• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Populating a selectbox a clean solution

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a form that accepts values from a selectbox.I am storing its via a formBean field(a string array).And I am passing control from one page to another via actionclass.Using normal page generation in struts i was able to list all array elements using ordinary bean:write(created using Wizard).

I want a listbox in page2 to be populated with this array list.

I am not saving anything to array in actionClass
Just tried writing
----------------------
<html:select property="formBeanName">
<html ptionsCollection="fieldNamefromFormBean"></html ption>\
------------------------------------
But failed to generate any output.

How can I get a fine solution rather than adding those details to arraylist and initialising arrays to fill its values.

I just want to use formBean field that stores the Array and I should be able to correctly populate the listbox in page2.

What can I do to achieve this?
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You lost me. Does your optionsCollection tag have a property attribute that you left off of your posted code? Are you saying that when the first page is submitted the list on your form gets populated?

- Brent
 
Dishpal Bhaluja
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I forgot to include the OptionsCollections property.
I achieved the same using an arrayList included in my action class.
Procedure followed:

Created a list and added list contents to session and used it.
And successfully populated the selection list.
<html:select name="formBean" property="check">
<html ptions name="myList"/>
</html:form>

Actually I populated my formBean chekField with a string array[].
My aim was to retrieve values and populate selection list i n another page.
But how can I directly populate selectionbox by specifying already populated check field.Where in this case I am filling an arrayList using elements i got from the formBean and adding this to session

But i dont want an array to be created and added to my session.
Any easy solution for this?
[ January 04, 2008: Message edited by: Dishpal Bhaluja ]
reply
    Bookmark Topic Watch Topic
  • New Topic