Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between binding and value tag

 
Yosi Pramajaya
Ranch Hand
Posts: 46
Java Netbeans IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, what's the different between binding and value tag?
It's all the same, doesn't it? Modifying and setting the value of a bean property.
What say you?
 
leo donahue
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you're talking about the difference between these?

The first one is just a value you supply.
The second one is a binding to a value that comes from your bean property.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18014
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think originally value tags didn't exist and binding was the only choice. Then a bunch of stale web pages kept Binding in view long after it was no longer the best solution.

Binding is a lot more cumbersome than value expressions. It introduces JSF-specific logic and constructs into what would otherwise be POJOs.

There are uses for bindings, however, just not as many as people actually use. Their primary benefit is that if you're not using a static View template, you can bind the View template to an "anchor" object that serves as container for the dynamic components and then construct the dynamic components in a backing bean, attaching them to their bound parent.
 
Yosi Pramajaya
Ranch Hand
Posts: 46
Java Netbeans IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks buddy, you both were really helpful.
But, if I want to make this code work :

and then I want to use the facesLogin.name in another page
like this:


How can I do that? xxx will be binding or value tag? or can be both of them?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18014
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Would be the proper value binding.

Your second example isn't actually JSF, it's EL going directly out to the view, so neither value nor binding apply. In JSF, you'd bind a value property like this:



Or you could split the difference:



That only works on output. Input value expressions have to reference a single property which will then be set when the form is submitted.
 
Yosi Pramajaya
Ranch Hand
Posts: 46
Java Netbeans IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Tim Holloway,
I think my problem has been resolved.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic