ServeletException, Property <variable name> not found

Posted by k9yosh on Stack Overflow See other posts from Stack Overflow or by k9yosh
Published on 2014-08-21T09:29:07Z Indexed on 2014/08/21 10:20 UTC
Read the original article Hit count: 231

Filed under:
|
|

What i'm trying to do is add a new variable to this previously created Managed Bean Hello.java and use it in my xhtml file binding to a text field. But it seems that it is not being found when i run it on the server. So it throws a "ServeletException" and says that the "property 'lname'(my variable) is not found". How do i solve this and why is this happening?

This is my managed bean,

package stack.tute.malinda.model;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean
@RequestScoped
public class Hello {
    private String fname;
    private String message;

    private String lname; //trying to add this new variable and use it in my xhtml file in a text field.

    public String getLname() {
        return lname;
    }
    public void setLname(String lname) {
        this.lname = lname;
    }
    public String getName() {
        return fname;
    }
    public String createMessage() {
        message="Hello " + fname + ""+ lname +"!";
        return null;
    }

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

    public String getMessage() {
        return message;
    }
}

This is my xhtml code,

<h:body>
<fieldset style="padding: 1em; float:left;  margin-right:0.5em; padding-top:0.2em; text-align:left; border:1px solid green; font-weight:bold;">
<legend>Personal Details</legend>
<h:form>
    <h:outputLabel for="name" value="First Name :" required="true"/>
    <h:inputText id="name" value="#{hello.name}"/>
    <br/>
     //Trying to access that variable here.
    <h:outputLabel for="name1" value="Last Name :" required="true"/>
    <h:inputText id="name1" value="#{hello.lname}"/>

    <h:message for="name"/>
    <br/>
    <h:commandButton value="Say hello" action="#{hello.createMessage}">
        <f:ajax execute="@form" render="@form"/>
    </h:commandButton>
    <br/>
    <h:outputText value="#{hello.message}"/>
</h:form>
</fieldset>

© Stack Overflow or respective owner

Related posts about jsf

Related posts about jsf-2