UIColumns loses rowIndex on renderColumnBody
--------------------------------------------

         Key: MYFACES-222
         URL: http://issues.apache.org/jira/browse/MYFACES-222
     Project: MyFaces
        Type: Bug
    Versions: 1.0.9 beta    
 Environment: myfaces-1.0.9
    Reporter: Mike Kienenberger


I'm using UIColumns (myfaces-1.0.9), and I've hit what appears to be a bug.
I can initialize my page, and then update my page, but I get an
IllegalArgumentException("row is unavailable") exception when the page
is being rendered (but after all of the actions for that page have
been processed).

The problem appears to be in here:

HtmlTableRendererBase.encodeChildren() contains:

                           columns.setRowIndex(k);
                           String columnStyle = styles.getColumnStyle(j);
                           renderColumnBody(facesContext, writer,
uiData, child, columnStyle);

k starts out as 0.  renderColumnBody() eventually calls

       UIColumns(UIData).isAllChildrenAndFacetsValid() line: 646
       UIColumns(UIData).encodeBegin(FacesContext) line: 594
       RendererUtils.renderChild(FacesContext, UIComponent) line: 482
       HtmlTableRenderer(HtmlTableRendererBase).renderColumnBody(FacesContext,
ResponseWriter, UIData, UIComponent, String) line: 205

and isAllChildrenAndFacetsValid cycles through the rowIndexes, and
ends up setting it to -1.

And then sometime later my own code gets called via

       HtmlSelectBooleanCheckbox(UIOutput).getValue() line: 75
       RendererUtils.getBooleanValue(UIComponent) line: 213
       HtmlCheckboxRenderer(HtmlCheckboxRendererBase).encodeEnd(FacesContext,
UIComponent) line: 94
       HtmlSelectBooleanCheckbox(UIComponentBase).encodeEnd(FacesContext) line: 
341
       RendererUtils.renderChild(FacesContext, UIComponent) line: 491
       RendererUtils.renderChildren(FacesContext, UIComponent) line: 468
       RendererUtils.renderChild(FacesContext, UIComponent) line: 489
       HtmlTableRenderer(HtmlTableRendererBase).renderColumnBody(FacesContext,
ResponseWriter, UIData, UIComponent, String) line: 205

but by this point, the rowIndex is -1 rather than the original 0 value
it should have been.

I "fixed" this in a 2005-04-29 CVS checkout with the following patch.
However, I don't claim to know if this will break something else.


Index: UIColumns.java
===================================================================
RCS file: 
/home/cvspublic/incubator-myfaces/src/share/org/apache/myfaces/component/UIColumns.java,v
retrieving revision 1.1
diff -u -r1.1 UIColumns.java
--- UIColumns.java      29 Mar 2005 11:40:50 -0000      1.1
+++ UIColumns.java      29 Apr 2005 22:27:45 -0000
@@ -15,7 +15,10 @@
  */
 package org.apache.myfaces.component;
 
+import java.io.IOException;
 import javax.faces.component.UIData;
+import javax.faces.context.FacesContext;
 
 /**
  * @author Mathias Broekelmann (latest modification by $Author: matzew $)
@@ -53,4 +56,18 @@
   {
     return COMPONENT_FAMILY;
   }
+  
+       public void encodeBegin(FacesContext context) throws IOException
+       {
+               int savedRowIndex = getRowIndex();
+               super.encodeBegin(context);
+               setRowIndex(savedRowIndex);
+       }
+
+       public void encodeEnd(FacesContext context) throws IOException
+       {
+               int savedRowIndex = getRowIndex();
+               super.encodeEnd(context);
+               setRowIndex(savedRowIndex);
+       }
 }


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to