• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

setting array values in formbean from jsp

 
Ranch Hand
Posts: 62
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
i have a small problem.

My ActionFormBean has a String [] named DealShortname
I want to populate this FormBean property in jsp from a textbox

What should the code written in jsp for the html:text look like???
ie how property attribute of ...html:text be written as

Thanks & Regards
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If, for example, you know your array is going to be a length of 5, write 5 <html:text> tags in your jsp, with property="dealShortname[x]" where x is 0 through 4. Then, in your ActionForm, add an indexed getter and setter for this property (e.g. getDealShortName(int index)).

Another way to do it would be to initialize the array in the action class that forwards to this jsp, and use the <logic:iterate> or <c:forEach> tag to iterate over the array.

Here is a useful link on indexed properties.

http://struts.apache.org/faqs/indexedprops.html
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic