javax.el.PropertyNotFoundException:类'没有可读的属性'preference' [英] javax.el.PropertyNotFoundException: The class ' does not have a readable property 'preference'

查看:91
本文介绍了javax.el.PropertyNotFoundException:类'没有可读的属性'preference'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经解决了几乎所有与SO有关的问题,但是找不到答案,因为我没有其他导致错误的原因,而我仍然有相同的错误结果.

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.

我已经实现了一个primefaces selectBooleanButton 元素,并且仅按此包括了bean代码.该错误意味着系统无法读取ManagedBean的属性,但是我有正确的getter/setter方法,因为它应该用于boolean属性.下面是供参考的代码:

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:

查看

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

错误:

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

请提出建议.

推荐答案

这个问题已经很长时间了,但发布此答案只是为了提及原因并解决问题.

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

glassfish没有选择更改并重新启动它可以解决此问题. 因此,如果您确定所做的更改仍然出现错误,我想也可以怀疑服务器了:)

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

这篇关于javax.el.PropertyNotFoundException:类'没有可读的属性'preference'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆