This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes To Authors: Difference between Value Binding and Component Binding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "To Authors: Difference between Value Binding and Component Binding" Watch "To Authors: Difference between Value Binding and Component Binding" New topic
Author

To Authors: Difference between Value Binding and Component Binding

Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
I can't see much difference between "value" and "binding" attribute apart from the fact that later one provides me the full component in at the server side.

Though I have read at many places that it's a cleaner way of getting access to whole component, but is that it's meant for?
Can there be a scenario when I should go for component binding rather than value binding ?
[ December 15, 2004: Message edited by: K Varun ]

- Varun
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
How about this scenario:

<h:inputText binding="My own sub-class of input Text">

Will this work, (Based on old java concept: Parent can reference a child object)?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by K Varun:
How about this scenario:

<h:inputText binding="My own sub-class of input Text">

Will this work, (Based on old java concept: Parent can reference a child object)?


In theory that should work as long as the parent class is HtmlInputXxxx. The only times I have ran into the need for component binding is if I need to manipulate a component when an ActionEvent is triggered. For example, say I need to disable a component based on a value selected from a HtmlSelectOneMenu component. On the valueChangeListener method I would need access to the component via java code, thus the component binding.

Yes, I know you could just adjust a flag and use the disabled="#{..}" but it was just an example.
[ December 15, 2004: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Originally posted by Gregg Bolinger:

The only times I have ran into the need for component binding is if I need to manipulate a component when an ActionEvent is triggered.

Yeah that's an option,
though you can use this approach too to get the component :
FacesContext.getCurrentInstance().getViewRoot().findComponent("your component Id")
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: To Authors: Difference between Value Binding and Component Binding
 
Similar Threads
Which Binding Type Do You Prefer And Why
What is the difference between 'deep' and 'shallow' binding?
Difference between value attribute and binding attribute
difference between value and binding
backing beans vs managed beans