Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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: 25472
180
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: 25472
180
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.
 
You don't like waffles? Well, do you like this tiny ad?
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic