Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The class does not have property [duplicate]

In my entity:

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(unique=true, nullable=false)
private int tId;
....
public int getTId() {
      return this.tId;
}

public void setTId(int tId) {
      this.tId = tId;
}

And code in my JSF page:

<ui:repeat value="#{techCat.techsOfCat}" var="post">
    <h:outputText value="#{post.getTId()}"/>
        ...
</ui:repeat>

The result is good. But if i code:

<ui:repeat value="#{techCat.techsOfCat}" var="post">
    <h:outputText value="#{post.tId}"/>
    ...
</ui:repeat>

I faced an error:

value="#{post.tId}": The class 'model.Technology' does not have the property 'tId'.

I really don't understand that error. Can you explain to me? Thanks

like image 408
Lost Heaven 0809 Avatar asked Aug 05 '13 15:08

Lost Heaven 0809


1 Answers

The error means that correct getters and setters could not be located for your property. The correct syntax for your getter and setter should be:

public int gettId() {
    return tId;
}

public void settId(int tId) {
    this.tId = tId;
}

If you are not sure- always use code generation for your getters and setters.

If you are interested in the specific convention, your getter and setter will relate to TId not tId.

like image 53
bjedrzejewski Avatar answered Nov 13 '22 11:11

bjedrzejewski