javax.el.PropertyNotFoundException: The class ' does not have a readable property 'preference'

我是研究僧i 提交于 2019-12-04 06:32:16

问题


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.


回答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 :)




回答2:


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;
}


来源:https://stackoverflow.com/questions/42664660/javax-el-propertynotfoundexception-the-class-does-not-have-a-readable-propert

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!