File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes populating a dropdown list from db Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
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://aspose.com/file-tools
 
subject: populating a dropdown list from db