Re: Binding problem in .jsp page
Mongoose wrote:
Thank you for your help . . . could you explain this line of code to
me?
binding="#{carstore.models.Jalopy.components.imageSmall}"
I have to admit I don't really understand what it refers to exactly???
I use the Java EE tutorial on Java Server Faces to help me on this
kind of thing:
<http://java.sun.com/javaee/5/docs/tutorial/doc/bnaph.html>
Step by step:
The 'binding' attribute links the control (e.g., command button) to a
JSF component, in your case a graphicImage.
That means that the Expression Language (EL) expression "#
{carstore.models.Jalopy.components.imageSmall}" needs to evaluate to
an appropriate JSF component on the Java side.
<http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html>
<http://java.sun.com/javaee/5/docs/tutorial/doc/bnaqm.html#bnaqp>
In EL, the "dot" notation does a couple of things.
One, it invokes a getter method or a setter method for an attribute,
thus
"carstore.models"
invokes the 'getModels()' method of the 'carstore' object defined in
the faces-config.xml.
Otherwise, it acts as an array or Map dereferencer, same as the square
brackets '[]' notation, so
"carstore.models.Jalopy"
looks up the Map value for which 'Jalopy' is the key.
So you look at the source code dot by dot, looking for either a get
method or a Map key that corresponds to the name in the dot notation.
carstore
- backing bean defined in faces-config.xml
models
- getModels() method of that bean
Jalopy
- key to a Map, specifically the Map returned by getModels()
components
- a collection or getter in the value object associated with
'Jalopy', I forget which
imageSmall
- a value retrieved from 'components'
That last value, 'imageSmall', must be a reference to a JSF component
because you used the 'binding' attribute.
--
Lew