-1

If we do something like this: <h:inputText id="name" value="#{customer.name}" />, then inputText can assign a value to name in customer if I understood correctly. How does this value assignment look like in code:

From what I found, it goes to inputText bean and there are setXXX and getXXX methods, but how does the bean or the upper level know to distinguish between each one of them from the above expression?

I'm missing the stages that are in between those two levels. I read the Oracle's tutorial on EL, but it doesn't mention a word on how to assign a value to existing expression. I also read about the <c:set tag, but I didn't see any place where it assign values to expressions.

EDIT: To be more accurate, I'm interested in how does the jsf input_text bean assigns a value to #{customer.name} . So what I found out is that it has to do something like this to give support for deferred expressions:

private javax.el.ValueExpression attributeName = null;

public void setAttributeName(
    javax.el.ValueExpression attributeName)
 {
    this.attributeName = attributeName;
}

Now my guess is there's some listener, that does something like attributeName.set(somehowGetContext(),whateverTheValueInInputTextBoxWasChangedTo). Could someone confirm it and tell me that this is what I'm supposed to do when I develop my own beans?

Vitali Pom
  • 602
  • 1
  • 8
  • 29

1 Answers1

0

In order to assign values to existing expression just create String name; as a global varaible and assign name = "Value"; (getter and setter should also be there) in the constructor of backing bean.

When you provide value="#{customer.name}" it mean the backing bean's name variable can be used in the UI. As simple as that.

A possible link for this question JSF value expressions and beans, how do they work?

Community
  • 1
  • 1
Kesavacharan
  • 318
  • 3
  • 14
  • At what part of code, which is between those two levels of a backing bean and our code the setter will be invoked? – Vitali Pom May 02 '15 at 21:36
  • Oh wait, so actually whenever I change after such assignment the value, backing bean's set will be called? Not only in JSF, but always – Vitali Pom May 03 '15 at 05:53