Details
-
Type:
Improvement
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.7DR#2
-
Fix Version/s: 1.7
-
Component/s: None
-
Labels:None
-
Environment:Apach 6.0.14, ice 1.7DR2, jsf 1.2.04
Description
When users got slectitems with null like:
<f:selectItem itemValue="" itemLabel="op default" />
<f:selectItem itemValue="0" itemLabel="op1" />
<f:selectItem itemValue="1" itemLabel="op2" />
may see this error:
java.lang.NumberFormatException: For input string: ""
java.lang.NumberFormatException.forInputString(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
java.lang.Short.parseShort(Unknown Source)
java.lang.Short.valueOf(Unknown Source)
java.lang.Short.valueOf(Unknown Source)
com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.isConversionMatched(MenuRenderer.java:663)
com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.isSelected(MenuRenderer.java:469)
With class version of this list like <f:selectItems> these errors are not occurs.
I think that this patch should be added to file
com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.java
Around line 649-653
private boolean isConversionMatched(String sentinel, Object selectedValue){
boolean match = false;
> if (sentinel!=null && sentinel.length()==0 && selectedValue==null){
> match = true;
> } else
if (selectedValue instanceof Long){
if (selectedValue.equals(Long.valueOf(sentinel))) {
<f:selectItem itemValue="" itemLabel="op default" />
<f:selectItem itemValue="0" itemLabel="op1" />
<f:selectItem itemValue="1" itemLabel="op2" />
may see this error:
java.lang.NumberFormatException: For input string: ""
java.lang.NumberFormatException.forInputString(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
java.lang.Short.parseShort(Unknown Source)
java.lang.Short.valueOf(Unknown Source)
java.lang.Short.valueOf(Unknown Source)
com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.isConversionMatched(MenuRenderer.java:663)
com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.isSelected(MenuRenderer.java:469)
With class version of this list like <f:selectItems> these errors are not occurs.
I think that this patch should be added to file
com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.java
Around line 649-653
private boolean isConversionMatched(String sentinel, Object selectedValue){
boolean match = false;
> if (sentinel!=null && sentinel.length()==0 && selectedValue==null){
> match = true;
> } else
if (selectedValue instanceof Long){
if (selectedValue.equals(Long.valueOf(sentinel))) {
On 1.7dr3 and current trunk the same problem and solution will by vaild
Correct patch
private boolean isConversionMatched(String sentinel, Object selectedValue){
{ > if (selectedValue==null) match = true; > }boolean match = false;
> if (sentinel!=null && sentinel.length()==0)
else
if (selectedValue instanceof Long){
Alternative code for <f:selectItems> test purpose. Work correct with jsf 1.2.
list = new ArrayList<SelectItem>();
list.add( new SelectItem( null ,"op default",""));
list.add( new SelectItem( new Short((short)0),"op1",""));
list.add( new SelectItem( new Short((short)1),"op2",""));
For the future I suggest to remove jsf 1.1 libraries from Icefaces distribution. Libraries from jsf 1.1 got several problems with converters and validators. People thinking there are icefaces problems.