javax.el.PropertyNotFoundException:类'没有可读属性'首选项'

问题描述 投票:0回答:2

我几乎已经完成了关于SO的所有相关问题,但找不到答案,因为我没有出现其他错误导致错误的问题。

我已经实现了一个primefaces selectBooleanButton元素,并且仅包含bean代码。该错误意味着系统无法读取managedBean的属性,但我有适当的getter / setter方法,因为它应该是boolean属性。以下是供参考的代码:

视图

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

豆:

@Named
@SessionScoped
public class SearchForm {

  private boolean preference;

  public boolean isPreference() {
      return preference;
  }

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

错误:

[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'.

请建议。

jsf primefaces el
2个回答
1
投票

对于这个问题已经很长时间了,但是发布这个答案只是为了提及原因并关闭问题。

玻璃鱼没有接受更改并重新启动它解决了问题。所以,如果您确定您的更改并仍然出现错误,我想可以怀疑服务器:)


1
投票

这是一个老问题,但这可能对某人有所帮助。我和Boolean有类似的问题。将getter方法从isXxx更改为getXxx解决了这个问题。例如:

public boolean getPreference() {
    return preference;
}
© www.soinside.com 2019 - 2024. All rights reserved.