[
http://jira.jboss.com/jira/browse/JBSEAM-880?page=comments#action_12353520 ]
Guy Veraghtert commented on JBSEAM-880:
---------------------------------------
Interesting discussion. How about following case ? (details left out)
<h:selectOneMenu value="#{bean.parent}"
valueChangeListener="#{...}">
<s:selectItems value="#{allParents}" noSelectionLabel="[Please
select]"/>
</h:selectOneMenu>
<h:selectOneMenu value="#{bean.child}" disabled="#{empty
bean.parent}">
<s:selectItems value="#{bean.parent.children}"
noSelectionLabel="[Please select]"/>
</h:selectOneMenu>
You have a screen with two dropdowns, the second isn't enabled until a selection is
made in the first one and allows you to choose one of the selected parent's children.
With the current implementation of UISelectItems, a dummy Parent must be returned by the
getParent() method on bean, not an existing one, otherwise that parent will be
pre-selected in the first dropdown, which we don't want.
If we don't provide this dummy parent, an exception will occur, because bean.parent
evaluates to null and hence also bean.parent.children, although a parent instance
getChildren() method always returns a non-null value.
When adding an empty list the user woudn't see an empty dropdown, but a disabled one,
with [Please Select] as the first value.
So, I would opt for the alternative with the empty list and a WARN message ;-), as you
could have guessed. (However, be careful that the log statement doesn't cause another
exception)
Make UISelectItems more permissive to null-values
-------------------------------------------------
Key: JBSEAM-880
URL:
http://jira.jboss.com/jira/browse/JBSEAM-880
Project: JBoss Seam
Issue Type: Patch
Components: JSF
Affects Versions: 1.1.7.GA
Reporter: Guy Veraghtert
Assigned To: Peter Muir
Priority: Minor
Fix For: 1.1.7.GA
Attachments: patch-880.txt
The method createSelectItems(Object value) in UISelectItems is not permissive to
null-values; a framework class should not die on NPE.
This can be fixed by assigning an empty list to value when value == null
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira