The moose likes Struts and the fly likes LabelValueBeans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "LabelValueBeans" Watch "LabelValueBeans" New topic
Author

LabelValueBeans

sudha swami
Ranch Hand

Joined: Apr 24, 2007
Posts: 179
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
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864

[ September 12, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
sudha swami
Ranch Hand

Joined: Apr 24, 2007
Posts: 179
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

Joined: Feb 15, 2005
Posts: 4864
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

Joined: Apr 24, 2007
Posts: 179
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

Joined: Feb 15, 2005
Posts: 4864
Originally posted by sudha swami:
I would like to retrive the options attribute in the <htmlptionCollection> tag with out using the form bean obj.

Sorry, but you can't do that. An <htmlptionsCollection> 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

Joined: Apr 24, 2007
Posts: 179
Thanks alot..
vive shar
Greenhorn

Joined: Sep 27, 2007
Posts: 17
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: LabelValueBeans