When to use binding="#{..}" rather than value="#{..}"
The app I'm working on was developed by another team. They used a lot of binding="#{..}" in their pages with Html* controls in their backing beans.
In the reading I've read I've seen little mention of binding=""; mostly things are done with value="". I've just spent a day chasing a bug where an HtmlOutputText control was displaying the wrong text. The reason for this was that even though the HtmlOutputText object was created and initialized with the correct text in the bean constructor, during the RENDER_RESPONSE phase that HtmlOutputText was replaced with one from the FacesContext cache, which contained the text from the first usage of that page.
I fixed it by changing to a value binding, but would like to understand when (or why) one would use a binding="". This also seems like it might be a performance hit because the page classes do new Html*() for all the bound controls, which then get replaced from a cache? I believe that JSF will create those controls if they haven't been constructed; then any initialization that the page requires could be done in a beforeRenderResponse() method?
I don't really want to go through the entire app changing the binding="#{..} to value="#{..}", but I need to correct anything could be impacting performance.
[1293 byte] By [
dderry650a] at [2007-11-26 16:20:29]

# 1
> When to use binding="#{..}" rather than value="#{..}"
Only if you want to have the control over the component and not only over it's value. Personally I only use componentbindings in h:dataTable (to retrieve the row selected) and when I want to dynamically create components in the backing bean for the JSF page (parentComponent.getChildren().add(new Component); and so on). Very sometimes I use it in certain form or input elements.
I guess that this webapp was developed in a nasty WYSIWYG drag'n'drop JSF editor for lazy and unexperienced developers, like the one Websphere has. Then the so-called "pagecode" with a heap of fairly meaningless code will be auto-generated.
# 2
> Only if you want to have the control over the
> component and not only over it's value. Personally I
> only use componentbindings in h:dataTable (to
> retrieve the row selected) and when I want to
> dynamically create components in the backing bean for
> the JSF page (parentComponent.getChildren().add(new
> Component); and so on). Very sometimes I use it in
> certain form or input elements.
That's pretty much what I thought. I haven't seen anything in this code that seemed to warrant that level of control though. What I've seen being done could be easily handled with the attributes on the component tags.
> I guess that this webapp was developed in a nasty
> WYSIWYG drag'n'drop JSF editor for lazy and
> unexperienced developers, like the one Websphere has.
> Then the so-called "pagecode" with a heap of fairly
> meaningless code will be auto-generated.
Boy you hit that nail square on the head! It was developed with Studio Creator. And the team was primarily very low-level people. But they were cheap!
Thanks for the reply,
Dave