aspose file tools*
The moose likes Struts and the fly likes LazyList pattern error... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "LazyList pattern error..." Watch "LazyList pattern error..." New topic
Author

LazyList pattern error...

Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Hi, following the instructions in this link...

http://wiki.apache.org/struts/StrutsCatalogLazyList


I was able to poppulate the member of type ArrayList in my bean... However, I could no longer retrieve the value using logic iterate... I do it like this...





and it gives the error (the one in bold letters)


HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Exception in JSP: /WEB-INF/pages/success.jsp:78

75:
76: Employment:
77:
78: <logic:iterate name="applicantFormBean" property="employmentHistory" id="employment" indexId="ctr">
79: a
80: <br/>
81: </logic:iterate>


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:388)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

javax.servlet.ServletException: No getter method for property employmentHistory of bean applicantFormBean
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.WEB_002dINF.pages.success_jsp._jspService(success_jsp.java:231)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:388)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

javax.servlet.jsp.JspException: No getter method for property employmentHistory of bean applicantFormBean
org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:1031)
org.apache.struts.taglib.logic.IterateTag.doStartTag(IterateTag.java:234)
org.apache.jsp.WEB_002dINF.pages.success_jsp._jspService(success_jsp.java:173)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:388)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.5.17



I'm quite sure I provided a getter method... Here's what the ApplicantFormBean looks like with the two getters for employmentHistory highlighted in bold letters...




I hope you could help me with this... Thanks!


SCJP 1.5
http://devpinoy.org/blogs/lamia/ - http://everypesocounts.com/
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Sometimes I think I understand how indexed properties work, but every time I use them I have to step back and think about it. I seem to recall having problems with having get and set method with the same name where the parameter and return types did not match. Instead of having overloaded versions of getEmploymentHistory, I would use unique names such as this:

public ArrayList<EmploymentFormBean> getEmploymentHistoryList()
public EmploymentFormBean getEmploymentHistoryItem(int index)

I would also remove the method setEmploymentHistory. Struts will not call this method, but if you need to from your code then rename it addEmploymentHistory. I am not sure that will solve the problem, but it seems worth a try.

- Brent
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Do I have to name my members appopriately, based on your suggestion? So if I rename my methods as


public ArrayList<EmploymentFormBean> getEmploymentHistoryList()
public EmploymentFormBean getEmploymentHistoryItem(int index)


I also have to rename my members to employmentHistoryList and employmentHistoryItem? Thanks for your reply!
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
I am not sure that you have to name your methods per my suggestion, but that is a convention that I have used. I remember working with another developer to track down an issue, and it was related to having mismatched get and set methods. You have a getEmploymentHistory that returns ArrayList<EmploymentFormBean> and a setEmploymentHistory method that takes an EmploymentFormBean as a parameter. At a minimum this violates the spirit of Java Bean properties.

I am not sure if the following example is 100% correct (plus I don't know the properties of your EmploymentFormBean class). The bean:write example does not submit back to the server, so you can just use the id value of the iterate tag. The html:text example uses a scriptlet and the html:checkbox uses the indexed property.

- Brent
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: LazyList pattern error...
 
Similar Threads
JSP
Multiple bundles broke my app(properties file)
Probelom in Manual Validation method
java.sql.DataTruncation: Data truncation
JCaptcha and Struts