RE: newbie html-el question
I am trying to display a value from a requestAttribute in an html-el:text ... but I can't get it to work. Here is my code: html-el:text: property=searchType value=%=request.getAttribute(searchType)%/ I recieve the error: Attribute searchType has no value Someone told me I have to do something more like this: html-el:text property=searchType value=${searchType}/ That's exactly what you should be doing but where would I define the variable searchType that is accessed there? searchType should be saved as an attribute of (preferably) your request object. Actually, a local variable should also work, you can define it using the c:set... JSTL tag. Actually, you shouldn't need to specify a value here at all. The html-el:text... tag will get the default value from your form bean. -- Tim Slattery [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: newbie html-el question
From: Bender, James [mailto:[EMAIL PROTECTED] I am trying to display a value from a requestAttribute in an html-el:text ... but I can't get it to work. Here is my code: html-el:text: property=searchType value=%=request.getAttribute(searchType)%/ I recieve the error: Attribute searchType has no value Someone told me I have to do something more like this: html-el:text property=searchType value=${searchType}/ but where would I define the variable searchType that is accessed there? You wouldn't, you'd set the property of the Form bean and let Struts handle it. If you need to pre-populate the form, you do that in the Action by calling setSearchType() on your Form bean. Then when you forward to the JSP, Struts will fill in the value. Can you explain more about your situation? I'm making some assumptions that may not be correct. In general there's no need to touch the 'value' attribute of the tags that render HTML form elements. -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: newbie html-el question
Hi Wendy, Thanks for responding! Someone showed me a way to do what I needed to do, but the way I'm approaching the entire problem may be kludged: The user can click Search Attributes | Search Components | Search Templates I've provided html:link's like these respectively: doPrepareSearch.do?searchType=attribute | doPrepareSearch.do?searchType=component | doPrepareSearch.do?searchType=template so when they user lands on my form, I want to prepopulate the search type based on what they chose. If they submit a search with bad data, then I'd want the SearchForm's (extends ActionForm) validate() method to send the back to the search form, this time keeping their most recent entries to the form field -- if they changed search type for example now it would be different. I am new to Struts and may not be getting a key concept of it's Best Practices usage. Does it make sense what I've described? Thanks again!, Jim -Original Message- From: Wendy Smoak [mailto:[EMAIL PROTECTED] Sent: Friday, March 26, 2004 2:03 PM To: Struts Users Mailing List Subject: RE: newbie html-el question From: Bender, James [mailto:[EMAIL PROTECTED] I am trying to display a value from a requestAttribute in an html-el:text ... but I can't get it to work. Here is my code: html-el:text: property=searchType value=%=request.getAttribute(searchType)%/ I recieve the error: Attribute searchType has no value Someone told me I have to do something more like this: html-el:text property=searchType value=${searchType}/ but where would I define the variable searchType that is accessed there? You wouldn't, you'd set the property of the Form bean and let Struts handle it. If you need to pre-populate the form, you do that in the Action by calling setSearchType() on your Form bean. Then when you forward to the JSP, Struts will fill in the value. Can you explain more about your situation? I'm making some assumptions that may not be correct. In general there's no need to touch the 'value' attribute of the tags that render HTML form elements. -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail transmission contains information that is confidential and may be privileged. It is intended only for the addressee(s) named above. If you receive this e-mail in error, please do not read, copy or disseminate it in any manner. If you are not the intended recipient, any disclosure, copying, distribution or use of the contents of this information is prohibited. Please reply to the message immediately by informing the sender that the message was misdirected. After replying, please erase it from your computer system. Your assistance in correcting this error is appreciated. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: newbie html-el question
From: Bender, James [mailto:[EMAIL PROTECTED] The user can click Search Attributes | Search Components | Search Templates I've provided html:link's like these respectively: doPrepareSearch.do?searchType=attribute | doPrepareSearch.do?searchType=component | doPrepareSearch.do?searchType=template When the user clicks one of those, Struts will populate the form associated with (I assume) PrepareSearchAction. Does the mapping for that have a 'name' attribute? Does that Form have get/setSearchType methods? If you need to remember data, it's often easiest to put the Form bean in session scope. And you can associate one Form to several different Actions if it makes sense for your application. Some people will argue against session scope, so you may want to consult the archives and see if their reasons apply to your situation. so when they user lands on my form, I want to prepopulate the search type based on what they chose. That will just magically happen if you let Struts populate the form from the query string parameter and then use the same Form bean when you display your HTML form using the JSP. Rather than confuse the issue, if you still need help, post your struts-config.xml so we can see what you've got. -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]