0

I have been through almost all the related questions on SO but couldn't find the answer because I don't have the issues that were the cause of errors for other still I've same error result.

I have implemented a primefaces selectBooleanButton element and included the bean code as per that only. The error means that the system is unable to read the property of the managedBean but I have proper getter/setter methods as it should be for boolean property. Below is the code for reference:

View

    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">
  <ui:composition template="/templates/common/public.xhtml">
    <ui:define name="title">Search</ui:define>
    <ui:define name="content">
      <div class="ui-grid ui-grid-responsive">
        <div class="ui-grid-row">
          <div class="ui-grid-col-10" id="mainCol">
            <h:form id="search">
              <h:panelGrid columns="2" cellpadding="5">
              <h:outputText value="Choose: " />
              <p:selectBooleanButton id="preference" value="#{searchForm.preference}" onLabel="Yes" offLabel="No" style="width:60px" />
            </h:form>
          </div>
        </div>
      </div>
    </ui:define>
  </ui:composition>
</html>

Bean:

@Named
@SessionScoped
public class SearchForm {

  private boolean preference;

  public boolean isPreference() {
      return preference;
  }

  public void setPreference(boolean preference) {
      this.preference = preference;
  }
}

Error:

[glassfish 4.1] [SEVERE] [] [javax.enterprise.resource.webcontainer.jsf.application] [tid: _ThreadID=26 _ThreadName=http-listener-1(2)] [timeMillis: 1488954548903] [levelValue: 1000] [[
  Error Rendering View[/search/searchForm.xhtml]
javax.el.PropertyNotFoundException: /search/searchForm.xhtml @49,156 value="#{searchForm.preference}": The class 'com.pc.SearchForm' does not have a readable property 'preference'.

Please suggest.

PC.
  • 132
  • 2
  • 14
  • Possible duplicate of [javax.el.PropertyNotFoundException: The class 'xxx' does not have a readable property 'yyy'](https://stackoverflow.com/questions/27769814/javax-el-propertynotfoundexception-the-class-xxx-does-not-have-a-readable-pro) – Kukeltje Jan 30 '19 at 19:32

2 Answers2

1

It been a long time for this question but posting this answer just to mention the cause and close the issue.

It was glassfish not picking up the changes and restarting it resolved the issue. So, if you are sure about your changes and still getting an error, I guess its ok to doubt the server too :)

PC.
  • 132
  • 2
  • 14
1

This is an old question but this may help somebody. I had a similar problem with Boolean. Changing the getter method from isXxx to getXxx solved it. For instance:

public boolean getPreference() {
    return preference;
}
Ahmet
  • 908
  • 1
  • 17
  • 26