This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Difference between binding and value tag

 
Ranch Hand
Posts: 48
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 24894
174
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 48
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 24894
174
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 48
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Tim Holloway,
I think my problem has been resolved.
 
reply
    Bookmark Topic Watch Topic
  • New Topic