my dog learned polymorphism
The moose likes Struts and the fly likes populating a dropdown list from db Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "populating a dropdown list from db" Watch "populating a dropdown list from db" New topic
Author

populating a dropdown list from db

Pritty GK
Greenhorn

Joined: Jun 01, 2007
Posts: 1
Hi All,
I am trying to pupulate a dropdown list with values from db is struts.

I have my getters and setters in my UserForm

UserForm.java
private List usertype = null;

public List getUsertype() {
return usertype;
}
public void setUsertype(List usertype) {
this.usertype = usertype;
}


UserAction.java

UserForm userForm = (UserForm) form;
ReferenceService refService = ReferenceService.getInstance();
List userType = null;
userType = refService.getListRef(Constants.USER_TYPE);
userForm.setUsertype(userType);



jsp page

<html:select property="usertype" name="userForm">
<html ptions collection="usertype" property="refCode" Property="refDesc" />
</html:select>



I am getting this error :
- Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: No getter method for property: "userType" of bean: "userForm"
at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:903)
at org.apache.struts.taglib.logic.IterateTag.doStartTag(IterateTag.java:233)
at org.apache.jsp.jsps.MaintUser_jsp._jspService(org.apache.jsp.jsps.MaintUser_jsp:266)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)


really needing some help on this...
Thanks
Pritty
Paras Jain
Ranch Hand

Joined: Feb 26, 2005
Posts: 137


Rename the variable "usertype" to "userType" . notice the change in case.

Also I am not sure if there is any attribute by the name Property for tag html ptions. There is an attibute called "property" but attribute "Property" may not work.(again, notice the change in case)


Paras Jain
SCJP 5.0
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: populating a dropdown list from db
 
Similar Threads
Populating 'html:select' with values in Database
Struts: Exception creating bean of class
My html:select is not working
Resource element in Tomcat 5.5 -- help needed
Issue in Struts Dropdown(Need Help Ranchers)