The class does not have property
37,022
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
.
Author by
Lost Heaven 0809
Updated on July 16, 2022Comments
-
Lost Heaven 0809 almost 2 years
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
-
BalusC almost 11 years-1 for saying that getter/setter are wrong (instead, it's the property name in EL which is wrong), +1 for pointing out a link with actually the right answer / technical explanation.
-
bjedrzejewski almost 11 yearsHe defines his property as 'private int tId' so I thought if he wants something that corresponds to this, he should use getters and setters as defined in my answer? You can also change the property name in EL of course. Or am I missing something?
-
BalusC almost 11 yearsEL properties do not correspond to private bean properties. They correspond to public bean getter/setter. The in your answer proposed getter/setter syntax is invalid according Javabeans specification (I haven't tested it, but I wouldn't be surprised if it still causes
PropertyNotFoundException
on certain EL impls/versions and/or bean introspection APIs). OP's original getter/setter syntax was valid, it's just the EL property name which is wrong based on the getter/setter syntax. -
bjedrzejewski almost 11 yearsThank you, so the point is simply that when thinking about EL properties, one should not be trying to make a link between them and variables in the class. I guess it depends what he is trying to achieve (variable name and EL name being the same seemed to me like his goal).