Select options tag
I have 20-25 combo-boxes in a single page.Each combo-box contains number of values and corresponding description. If I use a collection to populate all the options in all the combo-box,I have to define 20 javabeans and then keep them in scope. Is there any other easier way to do it using Struts Regards VasudevRao Gupta -Original Message- From: Tiago Henrique Costa Rodrigues Alves [mailto:[EMAIL PROTECTED] Sent: 08 December 2003 23:36 To: Struts Users Mailing List (E-mail) Subject: Struts User Roles Where can I find Struts Roles documentation? Tiago Henrique C. R. Alves - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How can I construct STRUTS select options tag according to a parameter ?
Hi there. How can I construct STRUTS select options tag according to a parameter ? I got a jsp named example_1.jsp. One accesses the page with a parameter like example_1.jsp?id=2 . Now what I wanna do is that the example_1.jsp get the value of id parameter and construct select options tag dynamically. Like below... String id = request.getParameter(id); USBean us = (USBean)request.getServletContext().getAttribute(USBean); StateBean state = us.getState(id); ArrayList cities = state.getCities(); All Beans above are set in the application scope when tomcat starts. I dont' know how to make us.getState(id) with STRUTS select options tag, since USBean's getState( ) method requires a id parameter. What I'm doing now is Using 1 more page ( actionExample.do ) right before the example_1.jsp. One accesses the actionExample.do with the id parameter like actionExample.do?id=2 and forward to example_1.jsp In the actionExample.do, get a value of the id parameter and StateBean accroding to the value. Set the StateBean in session scope like below. String id = request.getParameter(id); USBean us = (USBean)request.getServletContext().getAttribute(USBean); StateBean state = us.getState(id); request.getSession(true).setAttribute(state,state); then in example_1.jsp html:select property=state html:options collection=cities property=id labelProperty=name / /html:select I don't wanna do this anymore...since eveytime users accesses the actionExample.do , state bean is set in the session scope... Isn't this too much work ??? Thanks in advance. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How can I construct STRUTS select options tag according to aparameter ?
The simplest thing would be to have the Action create a LabelValue bean collection from state and cities, and pass that collection instead. http://jakarta.apache.org/struts/api/org/apache/struts/util/LabelValueBean.html A good practice is to use Actions to front any page that uses dynamic data. So, instead of linking to examnple_1.jsp, you would always link to a example_1.do (or equivalent) that ensured whatever data you need exists. The idea is that the Action does whatever is necessary to make the dynamic data easy to display. For a select control, the easiest format for the data is a collection of LabelValue beans, so that's the one the Action should prepare. For something like States, you could also store the collection in application scope at start up, using a plug-in, so that the Action would not need to create it. See the MailReader sample application, bundled with Struts, for a working example of using a plugin to create a LabelValue collection. -Ted. Fumitada Hattori wrote: Hi there. How can I construct STRUTS select options tag according to a parameter ? I got a jsp named example_1.jsp. One accesses the page with a parameter like example_1.jsp?id=2 . Now what I wanna do is that the example_1.jsp get the value of id parameter and construct select options tag dynamically. Like below... String id = request.getParameter(id); USBean us = (USBean)request.getServletContext().getAttribute(USBean); StateBean state = us.getState(id); ArrayList cities = state.getCities(); All Beans above are set in the application scope when tomcat starts. I dont' know how to make us.getState(id) with STRUTS select options tag, since USBean's getState( ) method requires a id parameter. What I'm doing now is Using 1 more page ( actionExample.do ) right before the example_1.jsp. One accesses the actionExample.do with the id parameter like actionExample.do?id=2 and forward to example_1.jsp In the actionExample.do, get a value of the id parameter and StateBean accroding to the value. Set the StateBean in session scope like below. String id = request.getParameter(id); USBean us = (USBean)request.getServletContext().getAttribute(USBean); StateBean state = us.getState(id); request.getSession(true).setAttribute(state,state); then in example_1.jsp html:select property=state html:options collection=cities property=id labelProperty=name / /html:select I don't wanna do this anymore...since eveytime users accesses the actionExample.do , state bean is set in the session scope... Isn't this too much work ??? Thanks in advance. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Ted Husted, Junit in Action - http://www.manning.com/massol/, Struts in Action - http://husted.com/struts/book.html, JSP Site Design - http://www.amazon.com/exec/obidos/ISBN=1861005512. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Populate select options with Integers
Hi, I'm trying to populate a drop down list with integers. Basically, I want the following to be generated: select option value=11/option option value=22/option option value=33/option option value=44/option /select Is there an easy way to do this? I can't seem to find anything in the documentation or on __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Populate select options with Integers
Have you looked at label-value? -Original Message- From: Dhruva B. Reddy [mailto:[EMAIL PROTECTED] Sent: March 31, 2003 3:00 PM To: Struts Users Mailing List Subject: Populate select options with Integers Hi, I'm trying to populate a drop down list with integers. Basically, I want the following to be generated: select option value=11/option option value=22/option option value=33/option option value=44/option /select Is there an easy way to do this? I can't seem to find anything in the documentation or on __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Populate select options with Integers
I'm not sure what you're referring to here. Is this another taglib? --- apachep2 [EMAIL PROTECTED] wrote: Have you looked at label-value? -Original Message- From: Dhruva B. Reddy [mailto:[EMAIL PROTECTED] Sent: March 31, 2003 3:00 PM To: Struts Users Mailing List Subject: Populate select options with Integers Hi, I'm trying to populate a drop down list with integers. Basically, I want the following to be generated: select option value=11/option option value=22/option option value=33/option option value=44/option /select Is there an easy way to do this? I can't seem to find anything in the documentation or on __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Populate select options with Integers
On Mon, 2003-03-31 at 16:03, Dhruva B. Reddy wrote: I'm not sure what you're referring to here. Is this another taglib? No, it is the org.apache.struts.util.LabelValueBean. http://jakarta.apache.org/struts/api/org/apache/struts/util/LabelValueBean.html --- apachep2 [EMAIL PROTECTED] wrote: Have you looked at label-value? -Original Message- From: Dhruva B. Reddy [mailto:[EMAIL PROTECTED] Sent: March 31, 2003 3:00 PM To: Struts Users Mailing List Subject: Populate select options with Integers Hi, I'm trying to populate a drop down list with integers. Basically, I want the following to be generated: select option value=11/option option value=22/option option value=33/option option value=44/option /select Is there an easy way to do this? I can't seem to find anything in the documentation or on __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- James Mitchell Software Developer/Struts Evangelist http://www.open-tools.org - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
generating select options from a previous select
Hello, I have a form with two select tags. I want the options for the second to be dependent on the option chosen for the first. What is the best way to accomplish this? If java script is the answer, how do I obtain the value of the option chosen in the first select (I'm new to web apps)? What I've tried to do is create the options for the second select in the form bean given the value of the first, but of course, the set method for the property associated with the first select is not called until the form is submitted. html:form action=/Go name=GoForm type=my.GoForm bean:message key=app.select.category/ html:select property=category html:options name=GoForm property=categoryCollection/ /html:select bean:message key=app.select.subcategory/ html:select property=subcategory html:options name=GoForm property=subcategoryCollection/ /html:select ... /html:form Thanks for helping, Kelly - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: generating select options from a previous select
There are some good one here: http://javascript.internet.com/forms/ Make sure what you pick is compatible with most browsers. -- James Mitchell Software Developer/Struts Evangelist http://struts.sourceforge.net/struts-atlanta/ -Original Message- From: Clauson, Kelly [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 1:46 PM To: [EMAIL PROTECTED] Subject: generating select options from a previous select Hello, I have a form with two select tags. I want the options for the second to be dependent on the option chosen for the first. What is the best way to accomplish this? If java script is the answer, how do I obtain the value of the option chosen in the first select (I'm new to web apps)? What I've tried to do is create the options for the second select in the form bean given the value of the first, but of course, the set method for the property associated with the first select is not called until the form is submitted. html:form action=/Go name=GoForm type=my.GoForm bean:message key=app.select.category/ html:select property=category html:options name=GoForm property=categoryCollection/ /html:select bean:message key=app.select.subcategory/ html:select property=subcategory html:options name=GoForm property=subcategoryCollection/ /html:select ... /html:form Thanks for helping, Kelly - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: generating select options from a previous select
AFAIK, you will have to use JavaScript. See the onChange() event handler in the JavaScript API. This is very simple to do. http://devedge.netscape.com/central/javascript/ Mark -Original Message- From: Clauson, Kelly [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 1:46 PM To: [EMAIL PROTECTED] Subject: generating select options from a previous select Hello, I have a form with two select tags. I want the options for the second to be dependent on the option chosen for the first. What is the best way to accomplish this? If java script is the answer, how do I obtain the value of the option chosen in the first select (I'm new to web apps)? What I've tried to do is create the options for the second select in the form bean given the value of the first, but of course, the set method for the property associated with the first select is not called until the form is submitted. html:form action=/Go name=GoForm type=my.GoForm bean:message key=app.select.category/ html:select property=category html:options name=GoForm property=categoryCollection/ /html:select bean:message key=app.select.subcategory/ html:select property=subcategory html:options name=GoForm property=subcategoryCollection/ /html:select ... /html:form Thanks for helping, Kelly - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: RowSetDynaClass, select options
No, it doesn't. At least it didn't for me. value from html:option value=%= firstName % doesn't work. It would be so great if there were a way to create a concatenated label for a select menu. Currently, I have a getDisplay() in some of my beans, which returns a concatenation of some other strings. I present it like this: html:select multiple=true size=10 property=addchosencourseids html:options collection=availablecourses labelProperty=displayLabel property=courseinstanceid / /html:select It would be so nice to create the option label dynamically. Then I could combine bean:message key=whatever/ tags with the bean values, or whatever. Best, Heather Buch Think this'll work: html:select property=myFormField size=1 logic:iterate id=name name=Names bean:define id=firstName name=name property=first_name/ html:option value=%= firstName % bean:write name=firstName/bean:write name=name property=last_name/ /html:option /logic:iterate /html:select Quoting Cook, Graham [EMAIL PROTECTED]: Hi, Im using the RowSetDynaClass to produce a java.util.List of values from a database which are displayed in the JSP as follows:- html:select property=myFormField size=1 html:options collection=Names property=first_name labelProperty=first_name / /html:select What I would like to do is concatenate two fields in the java.util.List and use that as the labelProperty so the HTML OPTIONS would have a value of firstname and a label of firstname and lastname. Has anyone got an idea on how to concatenate please? This message contains information that may be privileged or confidential and is the property of the Cap Gemini Ernst Young Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message . -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- Kris Schneider mailto:[EMAIL PROTECTED] D.O.Tech http://www.dotech.com/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] Heather Buch - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: RowSetDynaClass, select options
Heather, What exactly do you mean by doesn't work? Is an exception thrown? Is the output rendered incorrectly? Quoting Heather Buch [EMAIL PROTECTED]: No, it doesn't. At least it didn't for me. value from html:option value=%= firstName % doesn't work. It would be so great if there were a way to create a concatenated label for a select menu. Currently, I have a getDisplay() in some of my beans, which returns a concatenation of some other strings. I present it like this: html:select multiple=true size=10 property=addchosencourseids html:options collection=availablecourses labelProperty=displayLabel property=courseinstanceid / /html:select It would be so nice to create the option label dynamically. Then I could combine bean:message key=whatever/ tags with the bean values, or whatever. Best, Heather Buch Think this'll work: html:select property=myFormField size=1 logic:iterate id=name name=Names bean:define id=firstName name=name property=first_name/ html:option value=%= firstName % bean:write name=firstName/bean:write name=name property=last_name/ /html:option /logic:iterate /html:select Quoting Cook, Graham [EMAIL PROTECTED]: Hi, Im using the RowSetDynaClass to produce a java.util.List of values from a database which are displayed in the JSP as follows:- html:select property=myFormField size=1 html:options collection=Names property=first_name labelProperty=first_name / /html:select What I would like to do is concatenate two fields in the java.util.List and use that as the labelProperty so the HTML OPTIONS would have a value of firstname and a label of firstname and lastname. Has anyone got an idea on how to concatenate please? This message contains information that may be privileged or confidential and is the property of the Cap Gemini Ernst Young Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message . -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- Kris Schneider mailto:[EMAIL PROTECTED] D.O.Tech http://www.dotech.com/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] Heather Buch - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Kris Schneider mailto:[EMAIL PROTECTED] D.O.Tech http://www.dotech.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RowSetDynaClass, select options
Hi, Im using the RowSetDynaClass to produce a java.util.List of values from a database which are displayed in the JSP as follows:- html:select property=myFormField size=1 html:options collection=Names property=first_name labelProperty=first_name / /html:select What I would like to do is concatenate two fields in the java.util.List and use that as the labelProperty so the HTML OPTIONS would have a value of firstname and a label of firstname and lastname. Has anyone got an idea on how to concatenate please? This message contains information that may be privileged or confidential and is the property of the Cap Gemini Ernst Young Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message . -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: RowSetDynaClass, select options
Think this'll work: html:select property=myFormField size=1 logic:iterate id=name name=Names bean:define id=firstName name=name property=first_name/ html:option value=%= firstName % bean:write name=firstName/bean:write name=name property=last_name/ /html:option /logic:iterate /html:select Quoting Cook, Graham [EMAIL PROTECTED]: Hi, Im using the RowSetDynaClass to produce a java.util.List of values from a database which are displayed in the JSP as follows:- html:select property=myFormField size=1 html:options collection=Names property=first_name labelProperty=first_name / /html:select What I would like to do is concatenate two fields in the java.util.List and use that as the labelProperty so the HTML OPTIONS would have a value of firstname and a label of firstname and lastname. Has anyone got an idea on how to concatenate please? This message contains information that may be privileged or confidential and is the property of the Cap Gemini Ernst Young Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message . -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- Kris Schneider mailto:[EMAIL PROTECTED] D.O.Tech http://www.dotech.com/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
select, options, define???
I am still fighting .. help help!! I have a form with 10 login id displayed as text field and ther admin rights chosen from a drop down lists .. all drop down lists are same. looks like this .. Login Id1 AdminRight1 Login Id2AdminRight2 Login Id3AdminRight2 . . . Login IdnAdminRight1 How do i do it ??? any help, suggestion, advice hint .. all welcome .. thanks in advance ... Jitendra
RE: select, options, define???
you can create a collection for the rights and store it in application context when your application starts(may be in an initialization servlet). then use the html:select tag and html:options tag to render the admin picklist(s). you can use ten html:text tags for login fields or look into the possibility of using an array for login fields. -rana. -Original Message- From: Jitendra Singh [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 24, 2002 7:25 AM To: [EMAIL PROTECTED] Subject: select, options, define??? I am still fighting .. help help!! I have a form with 10 login id displayed as text field and ther admin rights chosen from a drop down lists .. all drop down lists are same. looks like this .. Login Id1 AdminRight1 Login Id2AdminRight2 Login Id3AdminRight2 . . . Login IdnAdminRight1 How do i do it ??? any help, suggestion, advice hint .. all welcome .. thanks in advance ... Jitendra -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Select options with non string property targets
Is it possible for me to have something like this: html:select property=userType html:options property=userTypes/ /html:select where on my ActionForm, I have something like this: public UserType getUserType() public Collection getUserTypes() public void setUserType(UserType type) I don't want to have to deal with the labels, but rather have the selected list object set into setUserType(UserType type). regards, Chris Burnley -- Popular tours sell out well in advance! Don't be disappointed! http://www.viator.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
how to dynamically generate select options from arrays
Hello list people I'm using struts 1.0. I have a User object with a string array availableGroups. I want to generate a select options list from this array in a jsp. Using a session bean of type User named currentUser, I can iterate the array like this: logic:iterate id=x name=currentUser property=availableGroups br /bean:write name=x / /logic:iterate but i can't work out how to do the same sort of thing but generating a select list. Well i can, but not using struts taglibs! Can anyone help? cheers matthew -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
Re: how to dynamically generate select options from arrays
did a RTFM and solved it: the session scope bean instance name is currentUser, the array is availableGroups... html:select property=group html:options name=currentUser property=availableGroups/ /html:select (property=group refers to a property in an ActionForm that deals with this form) cheers matthew On Wed, 13 Nov 2002 11:24:18 + matthew yee-king [EMAIL PROTECTED] wrote: I'm using struts 1.0. I have a User object with a string array availableGroups. I want to generate a select options list from this array in a jsp. Using a session bean of type User named currentUser, I can iterate the array like this: logic:iterate id=x name=currentUser property=availableGroups br /bean:write name=x / /logic:iterate but i can't work out how to do the same sort of thing but generating a select list. Well i can, but not using struts taglibs! -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
reuse select/options?
I have a form that repeats a credit card validation portion multiple times. What is the best way to only have to write html:select/html:options once? Is there a way to give the first use an id and then refer to that by reference? thx andy kriger -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
Re: reuse select/options?
No - but you can sure put the collection in application scope, if that data is static. Andy Kriger wrote: I have a form that repeats a credit card validation portion multiple times. What is the best way to only have to write html:select/html:options once? Is there a way to give the first use an id and then refer to that by reference? thx andy kriger -- Eddie Bush -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
Select Options
I am trying to find out how to make a select (dropdown list) selected a option at the time of the page is loaded. Sample 1) I selected a option from my dropdown box and and click submit button 2) The FormAction find that I did not entered all the requested text boxs and it redisplays the page at this time I would like the option I selected to be reselected! Johnathan Mark Smith Divisional Assistant Vice President Information Systems Division Phone: (201) 352-1387 Pager: (201) 718-1370 Email: [EMAIL PROTECTED] Text Messaging: [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Select Options
html:select property=name_of_property_in_form_bean Smith, Johnathan M. wrote: I am trying to find out how to make a select (dropdown list) selected a option at the time of the page is loaded. Sample 1) I selected a option from my dropdown box and and click submit button 2) The FormAction find that I did not entered all the requested text boxs and it redisplays the page at this time I would like the option I selected to be reselected! Johnathan Mark Smith Divisional Assistant Vice President Information Systems Division Phone: (201) 352-1387 Pager: (201) 718-1370 Email: [EMAIL PROTECTED] Text Messaging: [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Select Options
Can you please help me some more with details -Original Message- From: Carl Bacher [mailto:[EMAIL PROTECTED]] Sent: Monday, September 09, 2002 12:59 PM To: Struts Users Mailing List Subject: Re: Select Options html:select property=name_of_property_in_form_bean Smith, Johnathan M. wrote: I am trying to find out how to make a select (dropdown list) selected a option at the time of the page is loaded. Sample 1) I selected a option from my dropdown box and and click submit button 2) The FormAction find that I did not entered all the requested text boxs and it redisplays the page at this time I would like the option I selected to be reselected! -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Select Options
A good example is in the struts-exersize-tablib.war in the struts/webapps dir look at html-select.jsp You can create a collection of OptionBeans and select it or explicitly set each option. There are examples of both in this jsp. Mike - Original Message - From: Smith, Johnathan M. [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, September 09, 2002 1:01 PM Subject: RE: Select Options Can you please help me some more with details -Original Message- From: Carl Bacher [mailto:[EMAIL PROTECTED]] Sent: Monday, September 09, 2002 12:59 PM To: Struts Users Mailing List Subject: Re: Select Options html:select property=name_of_property_in_form_bean Smith, Johnathan M. wrote: I am trying to find out how to make a select (dropdown list) selected a option at the time of the page is loaded. Sample 1) I selected a option from my dropdown box and and click submit button 2) The FormAction find that I did not entered all the requested text boxs and it redisplays the page at this time I would like the option I selected to be reselected! -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Select Options
Hi Johnathan, I think you are getting confused with how it actually selects the value that the user intended. Think of it this way: html:select property=type html:options collection=someCollectionYouHaveSetInTheScope property=value labelProperty=label/ /html:select This means that when the form is submitted, the type parameter is sent to your action class with the value that they selected from the options. Because this is struts, if your FormBean happens to have a getType()/setType() method on it, that property will be set at form submission, and subsequently the html:select tag will get the value of that property and make sure that the corresponding option is selected in in the list. The options tag is simple, you set the collection attribute to a collection of objects which possess a getValue() and a getLabel() method, the values of these methods are used in the resulting option tag for the value attribute and the text that goes between the option/option tags respectively.. Make sense? Craig. - Original Message - From: Smith, Johnathan M. [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, September 09, 2002 1:01 PM Subject: RE: Select Options Can you please help me some more with details -Original Message- From: Carl Bacher [mailto:[EMAIL PROTECTED]] Sent: Monday, September 09, 2002 12:59 PM To: Struts Users Mailing List Subject: Re: Select Options html:select property=name_of_property_in_form_bean Smith, Johnathan M. wrote: I am trying to find out how to make a select (dropdown list) selected a option at the time of the page is loaded. Sample 1) I selected a option from my dropdown box and and click submit button 2) The FormAction find that I did not entered all the requested text boxs and it redisplays the page at this time I would like the option I selected to be reselected! -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Struts select/options tags usage...
Subject: Struts select/options tags usage... From: Scott Curtis [EMAIL PROTECTED] === Hi, I have a JSP with the following scriplet: % // Set up the server names list ServerNamesForm form = (ServerNamesForm)request.getAttribute(serverNamesForm); ArrayList list = form.getServerNames(); pageContext.setAttribute(serverNames, list); % The List list contains a collection of beans with value/labelProperty values in them. This code sets the list collection as an attribute of the pageContext, ready for use in the following code: html:select name=serverNamesForm property=theServerName html:options collection=serverNames property=value labelProperty=label / /html:select This works fine when simply loading the page. I then want the user to select an option from the displayed combo box and click a button whose action maps to anAction.do and subsequently an Action class that uses the selected values (hopefully now stored in the ServerNamesForm). The button looks like the following: input type=button name=submit value=Submit onclick=javascript:location='./anAction.do';/ Unfortunately when I click the button I get the following error message: javax.servlet.jsp.JspException: Cannot find bean under name serverNames at org.apache.struts.taglib.html.OptionsTag.getIterator(OptionsTag.java:343) at org.apache.struts.taglib.html.OptionsTag.doEndTag(OptionsTag.java:194) at /serverNames.jsp._jspService(/serverNames.jsp.java:327) I don't understand this as the page loads therefore the bean serverNames is clearly found. I am not sure what could be the problem with it? If that makes any sense and anyone can help I would be extremely grateful. Thanks - scott -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
how can I set the values in the form of a iteration (logic:iterate) on the select options (html:select)
Vehiclepark is a Bean with the property cars (cars is a collection of a Car). Car is a bean with the properties id and vehicleparkId hier ist my jsp-code logic:iterate name=Vehiclepark property=cars id=Car html:hidden name=Car property=id indexed=true/ html:select name=Car property=vehicleparkId indexed=true html:options name=allvehicleparkid / /html:select /logic:iterate and hier ist my VehicleparkForm: ArrayList cars = new ArrayList(); public ArrayList getCars() { return cars; } public void setCars(ArrayList cars) { this.cars = cars; } public Car getCars(int index) { return (Car) cars.get(index); } public void setCars(int index, Car car) { cars.set(index,car); } and hier ist my VehicleparkAction: I call this method vehicleparkForm.getCars() but I receive size()=0 nothing is saving in the form. I want to change the vehicleparkid and save the data in the form. How can I do it? Please Help -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Forcing a form-reload OR a select Options reload
I had to do something similar this last week and it was not as easy as I thought it would be :-) In your Javascript, you can call an action to reload this and then the action can return an ActionMapping back to your current page after a reload.Although note that your page will completely redraw itself :-)For that reason, I added a Javascript confirm() to ask the user if they really want to reload now or wait until the next time they visit the application. In many aspects, the User Interface for struts-related applications suffers greatly compared to the JFC/Swing way of doing it :-) Jesse Alexander (KADA 12) To: Struts Users Mailing List alexander.jesse[EMAIL PROTECTED] @csfs.com cc: Subject: RE: Forcing a form-reload OR a select Options 03/13/02 11:30 reload PM Please respond to Struts Users Mailing List Hi, Struts is a server-based application-environment... The functionality you describe is client-side... So the only option is to use Javascript to get this dynamic behaviour. This is live at the html-web-application programming side of live. Without Javascript the only way you can do something is, when the user sends a request to the server, cause only then your code can intervene. hope this helps Alexander Jesse -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Mittwoch, 6. März 2002 18:07 To: Struts Users Mailing List Subject: Forcing a form-reload OR a select Options reload Is there a way to cause an html select control to reload from a different collection -OR- to update the collection and have the html select be refreshed? If I have: html:select property=psdIndustryType size=1 html:options collection=psindustrytype property=value labelProperty=label/ Can I automatically repopulate the psindustrytype collection if the user clicks on a checkbox on the form?Is there a way to do this without having to resubmit the form? I am guessing not Another approach would be to have a javascript function (that gets called when the user clicks on a checkbox) call an Action. Is the best way to do that in Javascript use use the self.location=WhateverActionToCall thanks, Theron -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Forcing a form-reload OR a select Options reload
Hi, Struts is a server-based application-environment... The functionality you describe is client-side... So the only option is to use Javascript to get this dynamic behaviour. This is live at the html-web-application programming side of live. Without Javascript the only way you can do something is, when the user sends a request to the server, cause only then your code can intervene. hope this helps Alexander Jesse -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Mittwoch, 6. März 2002 18:07 To: Struts Users Mailing List Subject: Forcing a form-reload OR a select Options reload Is there a way to cause an html select control to reload from a different collection -OR- to update the collection and have the html select be refreshed? If I have: html:select property=psdIndustryType size=1 html:options collection=psindustrytype property=value labelProperty=label/ Can I automatically repopulate the psindustrytype collection if the user clicks on a checkbox on the form?Is there a way to do this without having to resubmit the form? I am guessing not Another approach would be to have a javascript function (that gets called when the user clicks on a checkbox) call an Action. Is the best way to do that in Javascript use use the self.location=WhateverActionToCall thanks, Theron -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: select/options/option
Hi Jason, As a matter of fact, I was going to add that. Now I have reason to. Thank you. :-) -- Larry Select can be used with: a: A collection of strings, such as an arraylist b: A collection of beans, each of which has string fields c: Hard coded values I know you can combine a and c, as well as b and c. I'm guessing you could combine a, b, and c as well. With An ArrayList of Strings ArrayList name is nameList. This list has been put into either the request or session. name of field in form bean to set is selectedValue. html:select property=selectedValue html:options name=nameList / /html:select How to Set a Selected Value --- Modify select as follows: html:select property=selectedValue value=aName html:options name=nameList / /html:select where aName is one of the names in the arrayList. With An ArrayList of Beans -- Bean string fields of interest are: 1. displayValue 2. idValue ArrayList name is beanList. This list has been put into either the request or session. name of field in form bean to set is selectedValue. It should be set to the idValue of the selected bean. html:select property=selectedValue html:options collection=nameList property=idValue labelProperty=displayValue/ /html:select How to Set a Selected Value --- Modify select as follows: html:select property=selectedValue value=aProperty html:options collection=nameList property=value labelProperty=longName/ /html:select where aProperty is one of the strings in the field of the bean specified by property in the options tag. With HardCoded Values - name of field in form bean to set is selectedValue. html:select property=selectedValue html:option value=value_1/ html:option value=value_2/ html:option value=value_3/ /html:select How to Set a Selected Value --- Modify select as follows: html:select property=selectedValue value=value_2 html:option value=value_1/ html:option value=value_2/ html:option value=value_3/ /html:select -Original Message- From: Jason Wells [mailto:[EMAIL PROTECTED]] Sent: Friday, January 11, 2002 5:49 PM To: Struts Users Mailing List Subject: Re: select/options/option Thanks for the summarized info. Using the html:option tag, is there a way to set an option to be initially selected? I'm looking for something equivalent to option value=blah selectedblah/option I don't see mention of this in the online docs for the HTML taglib. Thanks, Jason Larry Maturo wrote: Since I see these questions come up, and I just got them figured out, I thought I would share them with the mailing list. Select can be used with: a: A collection of strings, such as an arraylist b: A collection of beans, each of which has string fields c: Hard coded values I know you can combine a and c, as well as b and c. I'm guessing you could combine a, b, and c as well. With An ArrayList of Strings ArrayList name is nameList. This list has been put into either the request or session. name of field in form bean to set is selectedValue. html:select property=selectedValue html:options name=nameList / /html:select With An ArrayList of Beans -- Bean string fields of interest are: 1. displayValue 2. idValue ArrayList name is beanList. This list has been put into either the request or session. name of field in form bean to set is selectedValue. It should be set to the idValue of the selected bean. html:select property=selectedValue html:options collection=nameList property=idValue labelProperty=displayValue/ /html:select With HardCoded Values - name of field in form bean to set is selectedValue. html:select property=selectedValue html:option value=value_1/ html:option value=value_2/ html:option value=value_3/ /html:select -- Larry Maturo [EMAIL PROTECTED] Athens Group, Inc. -- Jason Wells Web Architect Xsilogy, Inc. http://www.xsilogy.com/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: select/options/option
Hello, On Fri, 11 Jan 2002 15:48:31 -0800 Jason Wells [EMAIL PROTECTED] wrote: Using the html:option tag, is there a way to set an option to be initially selected? I'm looking for something equivalent to option value=blah selectedblah/option I don't see mention of this in the online docs for the HTML taglib. This can be done by initializing the form-bean with the value you'd like to be selected by default. Very nice indeed. Bye, MM -- http://www.martinnet.de -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: select/options/option
The value which is returned from the property property in the select tag will make the choice for you if one of the choices matches this value. eg. Use the options tag running off a list, and if the property which is specified in the select tag matches one, Struts will select it for you. Arron. Jason Wells wrote: Thanks for the summarized info. Using the html:option tag, is there a way to set an option to be initially selected? I'm looking for something equivalent to option value=blah selectedblah/option I don't see mention of this in the online docs for the HTML taglib. Thanks, Jason Larry Maturo wrote: Since I see these questions come up, and I just got them figured out, I thought I would share them with the mailing list. Select can be used with: a: A collection of strings, such as an arraylist b: A collection of beans, each of which has string fields c: Hard coded values I know you can combine a and c, as well as b and c. I'm guessing you could combine a, b, and c as well. With An ArrayList of Strings ArrayList name is nameList. This list has been put into either the request or session. name of field in form bean to set is selectedValue. html:select property=selectedValue html:options name=nameList / /html:select With An ArrayList of Beans -- Bean string fields of interest are: 1. displayValue 2. idValue ArrayList name is beanList. This list has been put into either the request or session. name of field in form bean to set is selectedValue. It should be set to the idValue of the selected bean. html:select property=selectedValue html:options collection=nameList property=idValue labelProperty=displayValue/ /html:select With HardCoded Values - name of field in form bean to set is selectedValue. html:select property=selectedValue html:option value=value_1/ html:option value=value_2/ html:option value=value_3/ /html:select -- Larry Maturo [EMAIL PROTECTED] Athens Group, Inc. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: select/options/option
Thanks for the summarized info. Using the html:option tag, is there a way to set an option to be initially selected? I'm looking for something equivalent to option value=blah selectedblah/option I don't see mention of this in the online docs for the HTML taglib. Thanks, Jason Larry Maturo wrote: Since I see these questions come up, and I just got them figured out, I thought I would share them with the mailing list. Select can be used with: a: A collection of strings, such as an arraylist b: A collection of beans, each of which has string fields c: Hard coded values I know you can combine a and c, as well as b and c. I'm guessing you could combine a, b, and c as well. With An ArrayList of Strings ArrayList name is nameList. This list has been put into either the request or session. name of field in form bean to set is selectedValue. html:select property=selectedValue html:options name=nameList / /html:select With An ArrayList of Beans -- Bean string fields of interest are: 1. displayValue 2. idValue ArrayList name is beanList. This list has been put into either the request or session. name of field in form bean to set is selectedValue. It should be set to the idValue of the selected bean. html:select property=selectedValue html:options collection=nameList property=idValue labelProperty=displayValue/ /html:select With HardCoded Values - name of field in form bean to set is selectedValue. html:select property=selectedValue html:option value=value_1/ html:option value=value_2/ html:option value=value_3/ /html:select -- Larry Maturo [EMAIL PROTECTED] Athens Group, Inc. -- Jason Wells Web Architect Xsilogy, Inc. http://www.xsilogy.com/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
select/options/option
Since I see these questions come up, and I just got them figured out, I thought I would share them with the mailing list. Select can be used with: a: A collection of strings, such as an arraylist b: A collection of beans, each of which has string fields c: Hard coded values I know you can combine a and c, as well as b and c. I'm guessing you could combine a, b, and c as well. With An ArrayList of Strings ArrayList name is nameList. This list has been put into either the request or session. name of field in form bean to set is selectedValue. html:select property=selectedValue html:options name=nameList / /html:select With An ArrayList of Beans -- Bean string fields of interest are: 1. displayValue 2. idValue ArrayList name is beanList. This list has been put into either the request or session. name of field in form bean to set is selectedValue. It should be set to the idValue of the selected bean. html:select property=selectedValue html:options collection=nameList property=idValue labelProperty=displayValue/ /html:select With HardCoded Values - name of field in form bean to set is selectedValue. html:select property=selectedValue html:option value=value_1/ html:option value=value_2/ html:option value=value_3/ /html:select -- Larry Maturo [EMAIL PROTECTED] Athens Group, Inc. winmail.dat Description: application/ms-tnef -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Indexed properties with multiple select options
Hi - In my JSP I'm generating (a small unknown number) of multiselect SELECT drop-down lists with values taken from a Hashtable containing ArrayLists, such that each drop-down corresponds to the strings in an ArrayList in the Hashtable: % int n = 0; % logic:iterate id=attTab name=docDefAttList property=attTable % prop = attributeKeys[ + n + ]; n++; % bean:define id=atts name=attTab property=value / html:select property=%=prop % size=10 multiple=true html:options collection=atts property=docDefAttValKey labelProperty=docDefAttValDes/ /html:select /logic:iterate In the associated form bean, I assume I need to use an ArrayList (named attList below) which will contain the String[] arrays of selected values passed back from my SELECTs. So I have my indexed property String[] attributeKeys with getter and setter thus: public String[] getAttList(int idx) { return (String[])attList.get(idx); } public void setAttList(int idx, String[] keys) { attList.set(idx, keys); } But the problem is that this collapses in BeanUtils.populate with a type mismatch error: javax.servlet.ServletException: BeanUtils.populate at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:486) Root cause: java.lang.IllegalArgumentException: argument type mismatch at java.lang.reflect.Method.invoke(Native Method) at org.apache.struts.util.PropertyUtils.setIndexedProperty(PropertyUtils.java:688) I'm quite new to Struts, and can't understand what I'm doing wrong! Is it actually possible to use multiple select options with indexed properties? Any ideas? Thanks! Michael
Re: select options doesn't work
Hi! Try to change your property for the option to a boolean!! private String strValue; private boolean value; /Linnéa - Original Message - From: Pal, Gaurav [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, June 15, 2001 4:18 PM Subject: select options doesn't work Hi, I have been trying to get the select options tag to work in the html tag library. I tried to follow the sample code given in the struts-mailing list. I keep getting jsp exceptions at org.apache.struts.taglib.template.InsertTag.doEndTag ... The code snippets are below...any help is appreciated. Thanks, Gaurav jsp:useBean id=myBean scope=request type=com.xyz.MyForm / bean:define id=myList name=myBean property=marketList scope=request / html:select name=myBean property=marketList size=1 html:options collection=myList property=value labelProperty=description / /html:select Here is my bean with a Vector consisting of Option objects with value and description as the property. public class MyForm extends ActionForm { private Vector marketList; public void setMarketList(Vector marketList) { // SBgen: Assign variable this.marketList = marketList; } public Vector getMarketList() { // SBgen: Get variable return(marketList); } } class Option { private String strValue; private String strDescription; public void setValue(String value) { strValue = value; } public String getValue() { return strValue; } public void setDescription(String description) { strDescription = description; } public String getDescription() { return strDescription; } }
RE: select options doesn't work
Thanks for your suggestion - but it still doesn't work...I keep getting the same exception. Gaurav -Original Message- From: Linnea Ahlbeck [mailto:[EMAIL PROTECTED]] Sent: Friday, June 15, 2001 10:25 AM To: [EMAIL PROTECTED] Subject: Re: select options doesn't work Hi! Try to change your property for the option to a boolean!! private String strValue; private boolean value; /Linnéa - Original Message - From: Pal, Gaurav [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, June 15, 2001 4:18 PM Subject: select options doesn't work Hi, I have been trying to get the select options tag to work in the html tag library. I tried to follow the sample code given in the struts-mailing list. I keep getting jsp exceptions at org.apache.struts.taglib.template.InsertTag.doEndTag ... The code snippets are below...any help is appreciated. Thanks, Gaurav jsp:useBean id=myBean scope=request type=com.xyz.MyForm / bean:define id=myList name=myBean property=marketList scope=request / html:select name=myBean property=marketList size=1 html:options collection=myList property=value labelProperty=description / /html:select Here is my bean with a Vector consisting of Option objects with value and description as the property. public class MyForm extends ActionForm { private Vector marketList; public void setMarketList(Vector marketList) { // SBgen: Assign variable this.marketList = marketList; } public Vector getMarketList() { // SBgen: Get variable return(marketList); } } class Option { private String strValue; private String strDescription; public void setValue(String value) { strValue = value; } public String getValue() { return strValue; } public void setDescription(String description) { strDescription = description; } public String getDescription() { return strDescription; } }
RE: select options doesn't work
look at the subscription.jsp in the strutsexample. -Original Message- From: Pal, Gaurav [mailto:[EMAIL PROTECTED]] Sent: Friday, June 15, 2001 7:18 AM To: '[EMAIL PROTECTED]' Subject: select options doesn't work Hi, I have been trying to get the select options tag to work in the html tag library. I tried to follow the sample code given in the struts-mailing list. I keep getting jsp exceptions at org.apache.struts.taglib.template.InsertTag.doEndTag ... The code snippets are below...any help is appreciated. Thanks, Gaurav jsp:useBean id=myBean scope=request type=com.xyz.MyForm / bean:define id=myList name=myBean property=marketList scope=request / html:select name=myBean property=marketList size=1 html:options collection=myList property=value labelProperty=description / /html:select Here is my bean with a Vector consisting of Option objects with value and description as the property. public class MyForm extends ActionForm { private Vector marketList; public void setMarketList(Vector marketList) { // SBgen: Assign variable this.marketList = marketList; } public Vector getMarketList() { // SBgen: Get variable return(marketList); } } class Option { private String strValue; private String strDescription; public void setValue(String value) { strValue = value; } public String getValue() { return strValue; } public void setDescription(String description) { strDescription = description; } public String getDescription() { return strDescription; } }
RE: select options doesn't work
In your Form bean change your set method to take a string. public void setMarketList(String marketList) { } You will only get the item the user selected back in your bean, not the whole list. -Original Message- From: Kiet Nguyen To: '[EMAIL PROTECTED]' Sent: 6/15/2001 11:10 AM Subject: RE: select options doesn't work look at the subscription.jsp in the strutsexample. -Original Message- From: Pal, Gaurav [mailto:[EMAIL PROTECTED]] Sent: Friday, June 15, 2001 7:18 AM To: '[EMAIL PROTECTED]' Subject: select options doesn't work Hi, I have been trying to get the select options tag to work in the html tag library. I tried to follow the sample code given in the struts-mailing list. I keep getting jsp exceptions at org.apache.struts.taglib.template.InsertTag.doEndTag ... The code snippets are below...any help is appreciated. Thanks, Gaurav jsp:useBean id=myBean scope=request type=com.xyz.MyForm / bean:define id=myList name=myBean property=marketList scope=request / html:select name=myBean property=marketList size=1 html:options collection=myList property=value labelProperty=description / /html:select Here is my bean with a Vector consisting of Option objects with value and description as the property. public class MyForm extends ActionForm { private Vector marketList; public void setMarketList(Vector marketList) { // SBgen: Assign variable this.marketList = marketList; } public Vector getMarketList() { // SBgen: Get variable return(marketList); } } class Option { private String strValue; private String strDescription; public void setValue(String value) { strValue = value; } public String getValue() { return strValue; } public void setDescription(String description) { strDescription = description; } public String getDescription() { return strDescription; } }
Re: select options
The FormBean will be updated with the selection. Your DataBean will not be modified. -- Martin Cooper - Original Message - From: "Nick Pellow" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, March 08, 2001 3:16 PM Subject: Re: select options Martin Cooper wrote: It seems the documentation is wrong. It should be something like this instead: - 8 - The attribute name of the bean whose properties are consulted to determine which option should be pre-selected when rendering this input field. If not specified, the bean associated with the form tag we are nested within is utilized. [RT Expr] - 8 - As with the other form-related tags, I have never had to specify the name attribute, because I've always been able to use the default, meaning "use the form's bean". Hope this helps. Yes, that helps a lot. I want to do the above as I have a DataBean that stores commonly used lists of data. (credit card types, category names, brand names etc). I want to be able to use the same bean every time I want to display that data. Yet have my FormBean store the result of the users selection. Will the value on my FormBean be updated or the value on the DataBean be updated with the users selection? Cheers, Nick -- Martin Cooper - Original Message - From: "Nick Pellow" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, March 07, 2001 5:01 PM Subject: select options Hi, Looking at: http://jakarta.apache.org/struts/struts-html.html#select I notice that for the name attribute, the following description is given: name The fully-qualified java class name of the bean containing the underlying property. [RT Expr] Is this correct? I thought 'type' was usually used for class names and 'name' was used for variable names. Could someone please tell me what the name attribute means and when it should/shouldn't be used with select boxes? Cheers, Nick
Question/Problem using Multiple Select Options
Help! Unable to send back muliple select options. // Define the Array protected String[] geography; // Get the Array public String[] getGeography() { return (geography); } // Set the Array public void setGeography(String[] geography) { { this.geography = geography; } } Code In JSP Page ** html:select property="geography" multiple="true" size="2" html:options collection="cmProviderTypes" property="value" labelProperty="label" / /html:select This is only returning 1 value??? Has anyone done this successfully? I would really appreciate some help. Thanks in advance, Spencer
select options
Hi, Looking at: http://jakarta.apache.org/struts/struts-html.html#select I notice that for the name attribute, the following description is given: name The fully-qualified java class name of the bean containing the underlying property. [RT Expr] Is this correct? I thought 'type' was usually used for class names and 'name' was used for variable names. Could someone please tell me what the name attribute means and when it should/shouldn't be used with select boxes? Cheers, Nick
Re: select options
It seems the documentation is wrong. It should be something like this instead: - 8 - The attribute name of the bean whose properties are consulted to determine which option should be pre-selected when rendering this input field. If not specified, the bean associated with the form tag we are nested within is utilized. [RT Expr] - 8 - As with the other form-related tags, I have never had to specify the name attribute, because I've always been able to use the default, meaning "use the form's bean". Hope this helps. -- Martin Cooper - Original Message - From: "Nick Pellow" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, March 07, 2001 5:01 PM Subject: select options Hi, Looking at: http://jakarta.apache.org/struts/struts-html.html#select I notice that for the name attribute, the following description is given: name The fully-qualified java class name of the bean containing the underlying property. [RT Expr] Is this correct? I thought 'type' was usually used for class names and 'name' was used for variable names. Could someone please tell me what the name attribute means and when it should/shouldn't be used with select boxes? Cheers, Nick
Struggling with select/options
The examples I've seen using html:options name="someBean" property="someProperty" / all seem to reference a collection defined in the same jsp as the options tag. Could someone provide a rookie with an example where the collection bean is not defined in the same jsp, but rather by, say an action servlet or an application bean? For example, say I've got a User bean with a Vector of ints called Accounts. I'd like to display those accounts in a list-box - ultimately I'd like to display an associated name and use the int as the option value. I know that I can use labelName and labelProperty for this, but I haven't gotten the first part working yet. I'm able to get html:options collection= working, but I'm stumped on the other options mode. Most of the ways I've tried it result in class cast exceptions during the jsp compile. thank you, Marty La Jeunesse
RE: Struggling with select/options
Jean-Noel, merci beaucoup. Although using the collection mode of options, rather than name made, I'm accomplishing what I wanted to do. thanks again -Original Message- From: Jean-Nol Ribette [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 27, 2001 7:43 AM To: [EMAIL PROTECTED] Subject: Re: Struggling with select/options Did you put an int in your collection ? Did you try with a Integer ? Not in the collection of course but check you don't have an int which should be an Integer or a String somewhere.
RE: Select/Options Tag
Thanks for that. Got it passing a string array now. Managed to pass all options by calling a script function to select them all before posting. "Chalmers, Douglas" wrote: A tag reference can maintain a String from a SELECT statement within a form bean, but only the ONE actually selected.. How can I maintain ALL the OPTIONS within a SELECT box within a form bean?? This bug was just fixed, so you will need the most current nightly release. You can now have a property that returns a String array, and use it to back a SELECT statement that allows multiple options: html:select property="foo" multiple="true" ... Use html:option and/or html:options here ... /html:select and Struts will correctly remember all of the selected values, based on the contents of your array. There is a test page (html-select.jsp) in the Struts test application (struts-test.war) that illustrates how this works. Doug Chalmers Software Development Petrotechnics Ltd Exploration House Exploration Drive Aberdeen 707303 (Ext 14) Craig
Select/Options Tag
A tag reference can maintain a String from a SELECT statement within a form bean, but only the ONE actually selected.. How can I maintain ALL the OPTIONS within a SELECT box within a form bean?? Doug Chalmers Software Development Petrotechnics Ltd Exploration House Exploration Drive Aberdeen 707303 (Ext 14)
Re: Select/Options Tag
"Chalmers, Douglas" wrote: A tag reference can maintain a String from a SELECT statement within a form bean, but only the ONE actually selected.. How can I maintain ALL the OPTIONS within a SELECT box within a form bean?? This bug was just fixed, so you will need the most current nightly release. You can now have a property that returns a String array, and use it to back a SELECT statement that allows multiple options: html:select property="foo" multiple="true" ... Use html:option and/or html:options here ... /html:select and Struts will correctly remember all of the selected values, based on the contents of your array. There is a test page (html-select.jsp) in the Struts test application (struts-test.war) that illustrates how this works. Doug Chalmers Software Development Petrotechnics Ltd Exploration House Exploration Drive Aberdeen 707303 (Ext 14) Craig