-1

I think it's a small problem. I would like to modify the attibute value of p:menuButton that I want to take the value from my user bean (after his inscription in my application), such as take the name of the user (getName).

I did like :

<p:menuButton value="#{user.getName}">
            <p:menuitem value="My profile" action="#{toolbarView.edit}" update="" icon="ui-icon-disk" />
            <p:menuitem value="log out" actionListener="#{toolbarView.close}" update="" icon="ui-icon-arrowrefresh-1-w" />
</p:menuButton>

but I had this issue in my interface graphic (when I enter to my localhost):

type Exception report

message

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

exception

javax.servlet.ServletException: /profile.xhtml @55,53 value="#{user.getName}": Property 'getName' not found on type com.live.beans.User
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
root cause

javax.el.PropertyNotFoundException: /profile.xhtml @55,53 value="#{user.getName}": Property 'getName' not found on type com.live.beans.User
    com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111)
    javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
    org.primefaces.component.menubutton.MenuButton.getValue(MenuButton.java:96)
    org.primefaces.component.menubutton.MenuButtonRenderer.encodeButton(MenuButtonRenderer.java:64)
    org.primefaces.component.menubutton.MenuButtonRenderer.encodeMarkup(MenuButtonRenderer.java:53)
    org.primefaces.component.menu.BaseMenuRenderer.encodeEnd(BaseMenuRenderer.java:113)
    javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
    org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:88)
    org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:71)
    org.primefaces.component.column.renderer.PanelGridBodyColumnRenderer.encode(PanelGridBodyColumnRenderer.java:41)
    org.primefaces.component.column.ColumnRenderer.encodeEnd(ColumnRenderer.java:50)
    javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
    org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:88)
    org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:71)
    org.primefaces.component.row.renderer.PanelGridBodyRowRenderer.encode(PanelGridBodyRowRenderer.java:33)
    org.primefaces.component.row.RowRenderer.encodeEnd(RowRenderer.java:50)
    javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
    javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
    javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
    org.primefaces.component.panelgrid.PanelGridRenderer.encodeStaticBody(PanelGridRenderer.java:155)
    org.primefaces.component.panelgrid.PanelGridRenderer.encodeTableBody(PanelGridRenderer.java:104)
    org.primefaces.component.panelgrid.PanelGridRenderer.encodeTableLayout(PanelGridRenderer.java:65)
    org.primefaces.component.panelgrid.PanelGridRenderer.encodeEnd(PanelGridRenderer.java:37)
    javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
    com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)

And my bean user like :

@ManagedBean(name="user")
public class User {

    private int id;
    private String name;
    @Column(unique=true)
    private String email;
    private String password;
    private String confirmationPass;



    public User() {
        super();
    }

public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }


    public String getConfirmationPass() {
        return confirmationPass;
    }

    public void setConfirmationPass(String confirmationPass) {
        this.confirmationPass = confirmationPass;
    }


    public User(int id, String name, String email, String password,
            String confirmationPass) {
        super();
        this.id = id;
        this.name = name;
        this.email = email;
        this.password = password;
        this.confirmationPass = confirmationPass;
    }

    public User(int id, String name, String email, String password) {
        super();
        this.id = id;
        this.name = name;
        this.email = email;
        this.password = password;
    }

    public User(String name, String email, String password) {
        super();
        this.name = name;
        this.email = email;
        this.password = password;
    }

    @Override
    public String toString() {
        return "User [id=" + id + ", Name=" + name + ", email=" + email
                + ", password=" + password + "]";
    }


}

Also when I use user.name instead of user.getName I had nothing on my interface graphic like I did value=" " it display nothing in my interface graphic.

<p:menuButton value="#{user.name}">
            <p:menuitem value="My profile" action="#{toolbarView.edit}" update="" icon="ui-icon-disk" />
            <p:menuitem value="log out" actionListener="#{toolbarView.close}" update="" icon="ui-icon-arrowrefresh-1-w" />
</p:menuButton>

thanks for anyone who could help me

rene
  • 41,474
  • 78
  • 114
  • 152
  • `#{user.getName}` is wrong, `#{user.name}` is right as you can see alllll over the internet. If it is empty, search for the cause of that ( bean scoping?) – Kukeltje Jul 18 '15 at 07:33
  • @Kukeltje What you mean by bean scoping ? –  Jul 18 '15 at 09:22
  • http://stackoverflow.com/questions/7031885/how-to-choose-the-right-bean-scope – Kukeltje Jul 18 '15 at 10:05

1 Answers1

-2

OK, change your properti(value="#{user.getName}">) name from getName to name and then assingh in "user" back bean propertiy "name" with it's getters and settes.

Dijana Cukic
  • 196
  • 1
  • 9
  • I had add getters and setters as you see in my bean user, but when I do user.name it take it empty why ? –  Jul 18 '15 at 09:29