• 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

LabelValueBeans

 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have created the following LabelValueBean in the ActionForm. I would like to know, how i can retrieve the options data in the <html ptionsCollection >

Action Form:
LabelValueBean[] options = new LabelValueBean[31];

public LabelValueBean[] getOptions()
{
for (int i = 1; i <= 31; i++) {
options[i] = new LabelValueBean("Show topics for last " + String.valueOf(i) + " day", String.valueOf(i));
}
return options;
}




sudha
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

[ September 12, 2007: Message edited by: Merrill Higginson ]
 
sudha swami
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I tried to do the above approach but as i added the ActionForm in the requestAttribute it doesnt work. Could you please let me know, how should i do it?
regards
sudha
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The phrase "doesn't work" doesn't tell me anything useful. Please post the error message you're getting along with the stack trace if there is one. Also post the relevant portions of your JSP including the <html:form> tag, as well as relevant portions of your struts-config.xml file

One thing to check is to make sure that this Actionform is tied to the action specified in the <html:form> tag.
 
sudha swami
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
There is no ActionForm associated with the Action Class. Hence i am storing the options attribute in the request attribute.

Action Class:
-------------

request.setAttribute("options",sysEventsFormObj.getOptions());


Action Form:
------------
LabelValueBean[] options = new LabelValueBean[32];

public LabelValueBean[] getOptions()
{
for (int i = 1; i <= 31; i++) {
options[i] = new LabelValueBean("Show events for last " + String.valueOf(i) + " day", String.valueOf(i));
}
return options;
}

I would like to retrive the options attribute in the <html ptionCollection> tag with out using the form bean obj. Any help is appreciated on this.


regards
sudha
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sudha swami:
I would like to retrive the options attribute in the <html:optionCollection> tag with out using the form bean obj.


Sorry, but you can't do that. An <html:optionsCollection> tag must be inside an <html:form> tag which must point to an action that has an Actionform bean associated with it. There's no getting around this requirement.
 
sudha swami
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks alot..
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

If you don't want to use form bean object. You can create a hidden field and a js function. The js function will be called when you change the options in the dropdown.This js function will do two tasks.

1. Set the hidden field value to the selected value
2. submit the form.
3. get the value in the action using request.getParameter

Will this help to meet your requirement?

Thanks,
Vivek
 
Onion rings are vegetable donuts. Taste this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic