• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error reading 'items' on type gov.adjd.beans.TaskBean  RSS feed

 
wadha alketbi
Ranch Hand
Posts: 56
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have selectOneListbox that shows value from the DB when i run the jsp i have this error:

type Exception report

message /UI/AddTask.jsp(32,6) '#{taskBean.items}' Error reading 'items' on type gov.adjd.beans.TaskBean

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

exception
javax.servlet.ServletException: /UI/AddTask.jsp(32,6) '#{taskBean.items}' Error reading 'items' on type gov.adjd.beans.TaskBean
javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)



this is my managedbean:




my jsp page:



any help please,
Thank you in advance
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, you should not build your SelectItem list in the getItems() method. It's very inefficient and sometimes dangerous. For the most part, JSF bean "set" and "get" methods should only do simple data access and the logic to construct or act on the data should be done somewhere else.

Most likely, the code inside getItems() is throwing an Exception for some reason. JSF has a very bad habit of throwing away details on such exceptions when they happen in property accessor methods. That is another reason why it's a good idea to build the backing data somewhere else.
 
wadha alketbi
Ranch Hand
Posts: 56
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway, thank you for your answer and your help. acutely, in the begging i put the getItems method like that:


to see if its work with me or not but it shows the drop down menu with only Test1 which is correct. Now i want to read the value item and label item from the DB so i replace the previous method by this:



so, where is the right place for this method to get the values and labels from the DB?
Thank you again
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In some cases, you can do stuff like that in a @Postconstruct method, but I usually find it more flexible to cache things:


One advantage of this is that if I want to schedule an update/refresh of the items list, I can simply set the "items" property of the backing bean to null and the property-get method will automatically build and cache a new copy of the SelectItem list any time I want.
 
wadha alketbi
Ranch Hand
Posts: 56
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much, the drop down list shows without an error but it is empty
 
wadha alketbi
Ranch Hand
Posts: 56
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the TaskBean class, in side buildItem method there is a call for getStatusItmes and I have this method in business class that call another method in Dao class.
in the business calss:


and this method in DAO class:



may by the problem from these methods but there is no an error or exception in the console.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!