• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can�t set managed bean property�.

 
Pat Peg
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So here is the error message�

org.apache.jasper.JasperException: javax.servlet.jsp.JspException: javax.faces.FacesException: javax.faces.FacesException: Can't set managed bean property: 'Source'.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:476)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)

I am trying to use a database to check to see if a user should be able to �see� part of a page so on the jsp I do something like this�.

Rendered=�#{UserBean.Source}��.blah,blah,blah

config file is here�.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">

<faces-config >
<managed-bean>
<managed-bean-name>UserBean</managed-bean-name>
<managed-bean-class>com.Test.bean.UserBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<description>Field for the Source</description>
<property-name>Source</property-name>
<property-class>boolean</property-class>
<value></value>
</managed-property>

There is no real setting done of Source and the get method just calls the getRole method and passes in the role you are checking. getRole checks the database for a value and assigns a Boolean to pass back�

Here is the code�.

public final class UserBean extends Object {
public UserBean(){

public boolean getSource() {
return this.getRole("SOURCE");
}
public void setSource(boolean source) {
Source = source;
}
...

So why is there a problem with the set? I�ve done something that I swear would be identical on the same page in another area (another role all together) and it works fine.


 
Gabriel Claramunt
Ranch Hand
Posts: 375
Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You got me confused too
The only thing I would check is you defined setSource(boolean) and you have "<value></value>", not sure if the lack of value will affect.
Basically looks like you're trying to do setSource(null), which works with setSource(Boolean) but not with setSource(boolean).
Anyway, maybe I'm completely wrong ;)
 
Tak Ng
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this on your jsp page:

Rendered=�#{UserBean.source}�

As I know, bean property name should not start with a capital letter. Even if you have accessors called getSource and setSource, reference to this property in the jsp page should be #{UserBean.source} This is a Java convention.
 
Gabriel Claramunt
Ranch Hand
Posts: 375
Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you're right!
By the java bean conventions, the property should be small-case
[ June 19, 2007: Message edited by: Gabriel Claramunt ]
 
Pat Peg
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys-The caps was exactly the cause of the problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!