Question

public class SuperUser extends User implements Serializable{
  private static final long serialVersionUID = 1L;

  private String username;

  private String pin;

 //getters and setters
 }

when I use this in a managed bean and try to access it in the facelets file like this

<h:inputText id="firstName" value="#{userManager.superUser.firstName}" required="true" maxlength="30" size="30"/>

I get an exception

javax.el.PropertyNotFoundException: /superUser/create.xhtml @18,96 value="#{userManager.superUser.firstName}": Target Unreachable

Does that mean the you cannot extend java beans if you want to access their properties?

Thanks

Was it helpful?

Solution

It just means that #{userManager.superUser} returned null and hence setFirstName() cannot be called on it. JSF won't create nested object properties for you. You have to do it yourself.

To fix this, just ensure inside the backing bean class behind #{userManager} that it's not null. E.g.

private SuperUser superUser = new SuperUser();

OTHER TIPS

Is the method getFirstName() inside User class public?

Similarly, is getSuperUser() of the userManager managed bean public?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top