myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svieu...@apache.org
Subject cvs commit: incubator-myfaces/src/share/org/apache/myfaces/renderkit/html HtmlCheckboxRendererBase.java
Date Wed, 05 Jan 2005 23:06:45 GMT
svieujot    2005/01/05 15:06:45

  Modified:    src/share/org/apache/myfaces/renderkit RendererUtils.java
               src/share/org/apache/myfaces/renderkit/html
                        HtmlCheckboxRendererBase.java
  Log:
  Fix bug : checkbox wasn't looking at the submitted value.
  
  Revision  Changes    Path
  1.17      +59 -1     incubator-myfaces/src/share/org/apache/myfaces/renderkit/RendererUtils.java
  
  Index: RendererUtils.java
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/src/share/org/apache/myfaces/renderkit/RendererUtils.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- RendererUtils.java	14 Dec 2004 14:12:33 -0000	1.16
  +++ RendererUtils.java	5 Jan 2005 23:06:43 -0000	1.17
  @@ -36,6 +36,9 @@
    * @author Manfred Geiler (latest modification by $Author$)
    * @version $Revision$ $Date$
    * $Log$
  + * Revision 1.17  2005/01/05 23:06:43  svieujot
  + * Fix bug : checkbox wasn't looking at the submitted value.
  + *
    * Revision 1.16  2004/12/14 14:12:33  mmarinschek
    * PR:
    * Obtained from:
  @@ -81,6 +84,58 @@
       private static final Log log = LogFactory.getLog(RendererUtils.class);
   
       public static final String SELECT_ITEM_LIST_ATTR = RendererUtils.class.getName() +
".LIST";
  +    
  +    public static Object getValue(UIComponent component)
  +    {
  +        if (!(component instanceof ValueHolder))
  +        {
  +            throw new IllegalArgumentException("Component is not a ValueHolder");
  +        }
  +
  +        if (component instanceof EditableValueHolder)
  +        {
  +            Object submittedValue = ((EditableValueHolder)component).getSubmittedValue();
  +            if (submittedValue != null)
  +                return (Boolean)submittedValue;
  +        }
  +
  +        return ((ValueHolder)component).getValue();
  +    }
  +    
  +    public static Boolean getBooleanValue(UIComponent component)
  +    {
  +        if (!(component instanceof ValueHolder))
  +        {
  +            throw new IllegalArgumentException("Component is not a ValueHolder");
  +        }
  +
  +        if (component instanceof EditableValueHolder)
  +        {
  +            Object submittedValue = ((EditableValueHolder)component).getSubmittedValue();
  +            if (submittedValue != null)
  +            {
  +                if (submittedValue instanceof Boolean)
  +                {
  +                    return (Boolean)submittedValue;
  +                }
  +                else
  +                {
  +                    throw new IllegalArgumentException("Expected submitted value of type
Date");
  +                }
  +            }
  +        }
  +
  +        Object value = ((ValueHolder)component).getValue();
  +
  +        if (value==null || value instanceof Boolean)
  +        {
  +            return (Boolean) value;
  +        }
  +        else
  +        {
  +            throw new IllegalArgumentException("Expected submitted value of type Date");
  +        }
  +    }
       
       public static Date getDateValue(UIComponent component)
       {
  
  
  
  1.12      +7 -4      incubator-myfaces/src/share/org/apache/myfaces/renderkit/html/HtmlCheckboxRendererBase.java
  
  Index: HtmlCheckboxRendererBase.java
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/src/share/org/apache/myfaces/renderkit/html/HtmlCheckboxRendererBase.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- HtmlCheckboxRendererBase.java	23 Dec 2004 13:03:09 -0000	1.11
  +++ HtmlCheckboxRendererBase.java	5 Jan 2005 23:06:43 -0000	1.12
  @@ -78,8 +78,10 @@
               throws IOException {
           RendererUtils.checkParamValidity(facesContext, uiComponent, null);
           if (uiComponent instanceof UISelectBoolean) {
  +            Boolean value = RendererUtils.getBooleanValue( uiComponent );
  +            boolean isChecked = value != null ? value.booleanValue() : false;;
               renderCheckbox(facesContext, uiComponent, EXTERNAL_TRUE_VALUE,
  -                    null, ((UISelectBoolean) uiComponent).isSelected(), true);
  +                    null, isChecked, true);
           } else if (uiComponent instanceof UISelectMany) {
               renderCheckboxList(facesContext, (UISelectMany) uiComponent);
           } else {
  @@ -134,7 +136,8 @@
           for (Iterator it = RendererUtils.getSelectItemList(selectMany)
                   .iterator(); it.hasNext();) {
               SelectItem selectItem = (SelectItem) it.next();
  -            Object itemValue = selectItem.getValue();
  +            Object itemValue = selectItem.getValue(); // TODO : Check here for getSubmittedValue.
Look at RendererUtils.getValue
  +            
               String itemStrValue;
               if (converter == null) {
                   itemStrValue = itemValue.toString();
  
  
  

Mime
View raw message