Reputation: 15453
I'm having trouble evaluating a pair of boolean expressions within a JSF using EL.
Here's my snippet:
<a4j:commandButton id="addbtn" value="Add School(s)"
action="#{somebean.someaction}"
disabled="#{not studentRecords.isValid and not studentRecords.schoolSelected}">
</a4j:commandButton>
isValid and schoolSelected are returning boolean result either true or false. But when I'm connection these two with 'and' operator it does not work.
I tried putting
!studentRecords.isValid and !studentRecords.schoolSelected
But that doesn't also work.
Upvotes: 1
Views: 244
Reputation: 10463
EL expressions will automatically determine the correct managed bean property as long as the setters and getters were written correctly.
Managed Bean:
private Long studentRecordNumber;
public Long getStudentRecordNumber() {
return this.studentRecordNumber;
}
public void setStudentRecordNumber(Long studentRecordNumber) {
this.studentRecordNumber = studentRecordNumber;
}
JSF Markup
rednered="#{studentRecords.studentRecordNumber ne null}"
Managed Bean:
private boolean valid;
public boolean isValid() {
return this.valid;
}
public void setValid(boolean valid) {
this.valid = valid;
}
JSF Markup
rendered="#{not studentRecords.valid and not studentRecords.schoolSelected}"
EL expressions however can also be used to directly evaluate the returned result of a Boolean method, however method parentheses must be used.
rendered="#{studentRecords.canStudentEnrollToday()}"
Upvotes: 4