• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

LazyList pattern error...

 
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 751
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Good heavens! What have you done! Here, try to fix it with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic