开发者

jsf 2.0 bean extends another bean Target Unreachable, 'null' returned null [duplicate]

This question already has answers here: Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable 开发者_StackOverflow社区 (18 answers) Closed 7 years ago.
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


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();


Is the method getFirstName() inside User class public?

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜