Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What does # mean in <af:outputText value="#{bindings.DepartmentId.inputValue}"> ??  RSS feed

 
Vj Prakash
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone please explain what are we doing in this statement :

<af:outputText value="#{bindings.DepartmentId.inputValue}"

What does # stand for?
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, VJ!

The original Expression Language used "$" to indicate substitutable text, where the "${}" expression would be replaced with its corresponding value computed from model data.

However, that's a one-way trip. JSF requires the ability to also WRITE to model data. So the "#{}" expression format was created. The "#{}" expression indicates a REFERENCE to a value, not the value itself, so you can both read and write it.

In the case of the 'action="#{bean.method}"' construct, the reference is to an action method in a backing bean. That method must have a specific signature (no arguments, returns a navigation string). JSF invokes the action method automatically, so that's why the correct notation is 'action="#{bean.method}"' and not 'action="#{bean.method()}"'. The View Template does not "call" the method, just tells JSF what the method to be called is.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!