在类型上找不到属性

时间:2014-02-27 19:10:36

标签: java jsf jsf-2

我正在尝试在JSF中使用它来动态显示页面的标题。

<h:panelGroup rendered="#{not empty searchBean.fsResultsTitleOne}"><h2>#{msgs.fireStudySearchTitle}</h2></h:panelGroup>

我收到了这个错误:

rendered="#{not empty searchBean.fsResultsTitleOne}": Property 'fsResultsTitleOne' not found on type 

但是,我确实在类似的类型中定义了它:

private String fsResultsTitleOne;
public String getFSResultsTitleOne(){return fsResultsTitleOne;}
public void setFSResultsTitleOne(String newValue){fsResultsTitleOne = newValue;}

并将其设置为:

setFSResultsTitleOne("I'm not Empty!");

甚至用它来确保它会被设置:

System.out.println("This is the FS Results Page Title: " + fsResultsTitleOne);

它似乎正在发挥作用:

This is the FS Results Page Title: I'm not Empty!

我在某个地方做错了吗?

2 个答案:

答案 0 :(得分:2)

更改

getFSResultsTitleOne
setFSResultsTitleOne

getFsResultsTitleOne
setFsResultsTitleOne

答案 1 :(得分:1)

JSF访问代码中属性的方式是在属性名称中添加“ get ”,并以属性的第一个字母为大写。

E.g。如果您在xhtml页面中写为 -

value="#{myBean.name}"

良好的编码风格表明你必须拥有私人财产以及相应的吸气剂和制定者。因此,为了访问该属性,JSF解析器将转换请求如下 -

value = myBean.getName()

请注意, N 为大写字母。

因此,如果您像处理的那样弄乱了属性的名称,解析器将非常高兴抛出一个PropertNotFoundException。

相关问题