I know that similar errors are very common, and I've read hundreds (feels like) of posts about this, but still haven't been able to get it to work for me. So, I apologize for any repetition, but I would appreciate any help anyone can give me.
Thank you in advance for your assistance, Peter
I'm creating a collection (ArrayList) that I want to use for a form's select list. I've been trying to use the "html ptions collection" tag to populate the select list, but when I try to do that, it says it can't find the getter for the protocols, even though it's there, and the case is correct. I'm sure I'm not understanding something pretty basic, but have no idea what that could be. Thanks.
Error 500--Internal Server Error javax.servlet.jsp.JspException: No getter method for property: "protocols" of bean: "bdlLtsOclProtocols" at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:987) at org.apache.struts.taglib.bean.DefineTag.doEndTag(DefineTag.java:230) at jsp_servlet._pages.__dataentry2._jspService(__dataentry2.java:282) at weblogic.servlet.jsp.JspBase.service(JspBase.java:33) at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:446) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305) at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:301) at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085) at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263) at org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1023) at org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:345) at org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:572) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:221) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6364) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118) at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3641) at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Peter, We are pleased to have you here with us in the Struts forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
The <html:optionsCollection> tag is to be used when you have a collection of beans and you want one of the properties of the bean to represent the "value" of each <option> and another property to represent the label for that option. In your case, the label and the value are the same, and you don't have a collection of beans, but only a collection of Strings. In this case, you need to use the <html:options> tag.
<html:options name="protocolList" />
You could also get rid of both the <jsp:usebean> and the <bean:define> tags and write:
javax.servlet.jsp.JspException: No getter method available for property bdlLtsOclProtocols for bean under name org.apache.struts.taglib.html.BEAN
like it's looking for the getProtocols method in a generic struts bean rather than in the bdlLtsOclProtocols bean. Though before it was making that complaint about the bdlLtsOclProtocols bean.
I feel like I've tried just about every possible combination of options and select tags. Could it be a problem if the arrayList is coming from a different bean (bdlLtsOclProtocols) than the form is associated with? My understanding is that protocols in the form bean is a single string (the string that gets selected), whereas the for the select list, I'm using an arrayList.
It is your <html:select> tag that is causing this error, not your <html:options> tag. The property of your <html:select> tag must match one of the properties in your deDomForm bean. Since there is no bdlLtsOclProtocols property, that's why you're getting the message.
like you had it originally. [ July 12, 2006: Message edited by: Merrill Higginson ]
I apologize for my continued denseness, but it's still not working, even when I followed these suggestions.
Should I be populating my collection in the action class that forwards to the form? Or in the action class that goes from the form to the result page? It's still not clear to me how the collection fits in with the form, since the field in the form is a String, but my collection is an ArrayList.
With the following settings, I'm getting this error:
javax.servlet.jsp.JspException: No getter method available for property protocolss for bean under name px
I think we need to go a different direction here. The reason you're not successful at creating this application is that you don't understand the basic principles behind Struts and the Struts tags. My advice is to take some time out from your project and do some Struts tutorials or read a book on struts to get a better understanding of how this all works, and then come back to your application.
Here are the basic principles I've been trying to get across:
1-When you have a select/options combination box, you have two separate data elements: The list of available options, and the option the user actually selects. These two elements are separate data, and they come from separate locations. The option the user actually selects is represented by the property in the <html:select> tag. The list of available options is represented by the name and or property in the <html:options> tag. 2-Before displaying a jsp containing a select/options box, you must first populate the list of available options. Otherwise you'll get an error. 3-Your ActionForm must have a property that matches the property name specified in the <html:select> tag. The ActionForm bean does not have to have a property representing the list of options. It may, but it doesn't have to. A list of options can either be a property in the ActionForm bean, or it can be a bean that is placed in a scope. I usually find it convenient to put it in the ActionForm bean. 4-When the user selects an option and submits the form, Struts will populate the property in the ActionForm bean that you specified in the <html:select> tag with the option selected by the user.
To illustrate these principles, here's a simple Struts application. You start the application by entering http://myserver/myapp/initSelection.do to call the /initSelection action. It forwards to the selectionPage.jsp. When the user makes a selection and presses the submit button, the /processSelection action is called. I've tested it and know for sure that it works. Here are the relevant pieces:
[ July 16, 2006: Message edited by: Merrill Higginson ]
Thank you very much, that definitely clears some things up.
If I wanted to store that arrayList in some kind of context so that it could be read by multiple pages, would the best way to do that be via a struts plugIn referenced in struts-config.xml? Or via an action for the login page? I looked at the plugIn interface, and the init method looks like a place to do that, but I'd have to put it into servletContext, which is difficult to access from a jsp. So maybe I should do it from a login action, but I'm not sure if that's frowned upon in the struts world
Maybe I'm going about this the wrong way, but I've looked at way too many tutorials and books, all of them saying different things
I looked at the plugIn interface, and the init method looks like a place to do that, but I'd have to put it into servletContext, which is difficult to access from a jsp
If you want to put a list of values in Application scope (Same as ServletContext) so everyone can use it, the init() method of a class that implements the Plugin interface is a very good place to populate it. If the list is unique to one user, you should put the code in an Action class and store the bean in session scope.
Your statement that Application scope is difficult to access from a JSP is not at all true. When you specify a bean name and property in an <html ptions> tag, Struts searches for the bean in all scopes, including application scope.