[jira] Commented: (MYFACES-2927) Invalid handling of null values in listboxes and menus

2010-12-02 Thread Christian Kaltepoth (JIRA)

[ 
https://issues.apache.org/jira/browse/MYFACES-2927?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12966035#action_12966035
 ] 

Christian Kaltepoth commented on MYFACES-2927:
--

Hi Leonardo,

thank you very much for looking at this issue and applying my patch.

Just for your information: I had a quick look at the Mojarra source and saw 
that they do not use a converter if the current value is already a String.

See line 501 in HtmlBasicRenderer:

http://java.net/projects/mojarra/sources/svn/content/trunk/jsf-ri/src/main/java/com/sun/faces/renderkit/html_basic/HtmlBasicRenderer.java

In my opinion this behavior makes sense. Why should the renderer call 
Converter.getAsString() for a value that is already available in its String 
representation.

Just my two cents! :-)



 Invalid handling of null values in listboxes and menus
 --

 Key: MYFACES-2927
 URL: https://issues.apache.org/jira/browse/MYFACES-2927
 Project: MyFaces Core
  Issue Type: Bug
  Components: General
Affects Versions: 2.0.1
Reporter: Christian Kaltepoth
Assignee: Leonardo Uribe
 Fix For: 2.0.3-SNAPSHOT

 Attachments: MYFACES-2927.patch


 I discovered that MyFaces doesn't seem to handle null values correctly in 
 listboxes and menus.
 See the following example showing a h:selectOneMenu used to select an enum 
 value:
   @ManagedBean
   @RequestScoped
   public class TestBean {
  public enum Level {
 HIGH, MEDIUM, LOW
  }
  private Level level;
  public String action() {
 FacesContext.getCurrentInstance().addMessage(null, 
   new FacesMessage(Submitted level:  + level));
 return null;
  }
   }
 And the following view:
   h:selectOneMenu value=#{testBean.level} label=Level
 f:selectItem itemValue=#{null} itemLabel=Unknown/
 f:selectItem itemValue=HIGHitemLabel=High/
 f:selectItem itemValue=MEDIUM  itemLabel=Medium/
 f:selectItem itemValue=LOW itemLabel=Level/
   /h:selectOneMenu
   h:commandButton action=#{testBean.action} value=Go/
 Clicking the Go button will result in the validation error: Level: 
 'Unknown' must be convertible to an enum.
 If the value of the select item is null, MyFaces won't render the value 
 attribute of the option and so the browser will submit the label as its value:
   select id=levelForm:level name=levelForm:level size=1   
 option selected=selectedUnknown/option  
 option value=HIGHHigh/option
 option value=MEDIUMMedium/option
 option value=LOWLevel/option
   /select
 Mojarra instead renders an empty value attribute in this situation:
   option value= selected=selectedUnknown/option
 I've created a patch fixing this issue against the current trunk of 
 myfaces-shared and attached it to this ticket.
 You can see the sample application reproducing this issue here:
 http://github.com/chkal/myfaces-tests/tree/menu-null-value
 And download it here:
 http://github.com/chkal/myfaces-tests/archives/menu-null-value

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Commented: (MYFACES-2927) Invalid handling of null values in listboxes and menus

2010-12-02 Thread Jakob Korherr (JIRA)

[ 
https://issues.apache.org/jira/browse/MYFACES-2927?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12966038#action_12966038
 ] 

Jakob Korherr commented on MYFACES-2927:


Hi Christian,

Actually this is a Mojarra bug! A JSF impl should call converter.getAsString() 
even if the value is already a String, when a fitting converter is available.

For more details see the description of the mojarra issue at 
http://java.net/jira/browse/JAVASERVERFACES-1694

However, thanks a lot for your contribution ;)

Regards,
Jakob

 Invalid handling of null values in listboxes and menus
 --

 Key: MYFACES-2927
 URL: https://issues.apache.org/jira/browse/MYFACES-2927
 Project: MyFaces Core
  Issue Type: Bug
  Components: General
Affects Versions: 2.0.1
Reporter: Christian Kaltepoth
Assignee: Leonardo Uribe
 Fix For: 2.0.3-SNAPSHOT

 Attachments: MYFACES-2927.patch


 I discovered that MyFaces doesn't seem to handle null values correctly in 
 listboxes and menus.
 See the following example showing a h:selectOneMenu used to select an enum 
 value:
   @ManagedBean
   @RequestScoped
   public class TestBean {
  public enum Level {
 HIGH, MEDIUM, LOW
  }
  private Level level;
  public String action() {
 FacesContext.getCurrentInstance().addMessage(null, 
   new FacesMessage(Submitted level:  + level));
 return null;
  }
   }
 And the following view:
   h:selectOneMenu value=#{testBean.level} label=Level
 f:selectItem itemValue=#{null} itemLabel=Unknown/
 f:selectItem itemValue=HIGHitemLabel=High/
 f:selectItem itemValue=MEDIUM  itemLabel=Medium/
 f:selectItem itemValue=LOW itemLabel=Level/
   /h:selectOneMenu
   h:commandButton action=#{testBean.action} value=Go/
 Clicking the Go button will result in the validation error: Level: 
 'Unknown' must be convertible to an enum.
 If the value of the select item is null, MyFaces won't render the value 
 attribute of the option and so the browser will submit the label as its value:
   select id=levelForm:level name=levelForm:level size=1   
 option selected=selectedUnknown/option  
 option value=HIGHHigh/option
 option value=MEDIUMMedium/option
 option value=LOWLevel/option
   /select
 Mojarra instead renders an empty value attribute in this situation:
   option value= selected=selectedUnknown/option
 I've created a patch fixing this issue against the current trunk of 
 myfaces-shared and attached it to this ticket.
 You can see the sample application reproducing this issue here:
 http://github.com/chkal/myfaces-tests/tree/menu-null-value
 And download it here:
 http://github.com/chkal/myfaces-tests/archives/menu-null-value

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Commented: (MYFACES-2927) Invalid handling of null values in listboxes and menus

2010-12-02 Thread Christian Kaltepoth (JIRA)

[ 
https://issues.apache.org/jira/browse/MYFACES-2927?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12966049#action_12966049
 ] 

Christian Kaltepoth commented on MYFACES-2927:
--

Hi Jakob,

thank you very much for the clarification. I checked the issue and totally 
agree to your argumentation. Mojarra isn't spec compliant regarding this.

Regards

Christian

 Invalid handling of null values in listboxes and menus
 --

 Key: MYFACES-2927
 URL: https://issues.apache.org/jira/browse/MYFACES-2927
 Project: MyFaces Core
  Issue Type: Bug
  Components: General
Affects Versions: 2.0.1
Reporter: Christian Kaltepoth
Assignee: Leonardo Uribe
 Fix For: 2.0.3-SNAPSHOT

 Attachments: MYFACES-2927.patch


 I discovered that MyFaces doesn't seem to handle null values correctly in 
 listboxes and menus.
 See the following example showing a h:selectOneMenu used to select an enum 
 value:
   @ManagedBean
   @RequestScoped
   public class TestBean {
  public enum Level {
 HIGH, MEDIUM, LOW
  }
  private Level level;
  public String action() {
 FacesContext.getCurrentInstance().addMessage(null, 
   new FacesMessage(Submitted level:  + level));
 return null;
  }
   }
 And the following view:
   h:selectOneMenu value=#{testBean.level} label=Level
 f:selectItem itemValue=#{null} itemLabel=Unknown/
 f:selectItem itemValue=HIGHitemLabel=High/
 f:selectItem itemValue=MEDIUM  itemLabel=Medium/
 f:selectItem itemValue=LOW itemLabel=Level/
   /h:selectOneMenu
   h:commandButton action=#{testBean.action} value=Go/
 Clicking the Go button will result in the validation error: Level: 
 'Unknown' must be convertible to an enum.
 If the value of the select item is null, MyFaces won't render the value 
 attribute of the option and so the browser will submit the label as its value:
   select id=levelForm:level name=levelForm:level size=1   
 option selected=selectedUnknown/option  
 option value=HIGHHigh/option
 option value=MEDIUMMedium/option
 option value=LOWLevel/option
   /select
 Mojarra instead renders an empty value attribute in this situation:
   option value= selected=selectedUnknown/option
 I've created a patch fixing this issue against the current trunk of 
 myfaces-shared and attached it to this ticket.
 You can see the sample application reproducing this issue here:
 http://github.com/chkal/myfaces-tests/tree/menu-null-value
 And download it here:
 http://github.com/chkal/myfaces-tests/archives/menu-null-value

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.