Kurt Edegger wrote:
Simon,
unfortunately they don't have the sources published directly on this
site but provide the jar file
(http://www.exadel.com/tutorial/jsf/misc/jsftags-guide.jar)
to download.
Let me post the carBean class to show that 'carBean.currentCar' accesses
the SelectItem directly [1]:
public class CarBean {
//[1] carBean.currentCar accesses SelectItem
public SelectItem getCurrentCar () {
return new SelectItem("nissan-z","Nissan Z350","Nissan Z350 -
sports");
}
Hmm..interesting. Thanks for posting that.
The main classes involved here are
HtmlSelectOneMenu : extends UISelectOne
HtmlMenuRendererBase
What is contained in the request parameters on postback is definitely
the "value" string associated with the selected <OPTION> tag. The
HtmlMenuRendererBase.decode
method calls
HtmlRendererUtils.decodeUISelectOne
which just stores this string as the component's submittedValue. During
the validation phase, method
_SharedRendererUtils.findUIOutputConverter
is called to create a "converter" that maps the string into the
appropriate type. This class inspects the type of the method specified
by the "value" binding to determine the desired final type, then asks
the Application object for an appropriate Converter.
However I can't see any Converter class in MyFaces that is capable of
doing String->SelectItem conversion. The Converter methods do get passed
the associated UIComponent, so potentially such a converter could access
its parent component in order to iterate over its child SelectItem objects.
It must be possible, as the example jar clearly does it. However I can't
figure out *how* the UISelectOneMenu can use a value-binding dealing in
SelectItem instances. I'd be very happy if someone could explain!
Of course, specifying the "value" binding as a primitive property
(String/int/etc) works fine.
Cheers,
Simon