0

I'm trying to use this in JSF to dynamically show the title of a page.

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

And I'm getting this error:

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

However, I did define it in on the type like this:

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

And set it to something:

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

And even used this to make sure it would be set:

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

And it seems to be working:

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

Am I setting it wrong someplace?

UndefinedReference
  • 1,223
  • 4
  • 22
  • 52

2 Answers2

2

Change

getFSResultsTitleOne
setFSResultsTitleOne

to

getFsResultsTitleOne
setFsResultsTitleOne
Smutje
  • 17,733
  • 4
  • 24
  • 41
2

The way how JSF accesses the properties in your code is it adds a "get" to the property name with the first letter of the property in caps.

E.g. If you write in the xhtml page as -

value="#{myBean.name}"

Good coding style says you must have private property with respective getters and setters. So JSF parser in order to access the property will convert the request as following-

value = myBean.getName()

Note that the N is in caps.

So if you mess with the name of the property as you did, the parser will be happy enough to throw a PropertNotFoundException.

Manish
  • 710
  • 3
  • 12
  • 25