-
1. Re: c:forEach and h:column
limousyf Jul 24, 2007 9:41 AM (in response to limousyf)Now I have an error regarding the usage of DataModel:
<c:forEach items="#{TestCrossDataTable.boiteNoireSimple.columnDataModel}"> Must evaluate to a Collection, Map, Array, or null.
I cannot use a DataModel in a JSTL Tag ? (Well, sounds normal as a matter of fact ...)
How it is suppose to iterate over the page ?
In my plain old JSF/Myfaces project, the iteration process was made using isRowAvailable() and getRowData() to get the correct Cell (Line X Column) ... -
2. Re: c:forEach and h:column
limousyf Jul 24, 2007 12:05 PM (in response to limousyf)Ok, after using a Datamodel for the lines and a List for the columns, I finally managed to get this (half-)working.
To get the correct Cell, containing my object, I :
- iterate over lines using isRowAvailable() and getRowData()
- iterate over the columns using an int going from 0 to myList.size()
in a method named getCellValue() in my backing bean.
This works pretty well If I fetch only one time the cell content (the column counter is incremented one time per cell).
But If need to fetch multiple times the cell (it's an object containing the value, a boolean for rendering, etc ...) then it doesn't work.
My column counter is incremented bean-side, so it doesn't care if I'm still on the same cell jsf-side ...
When I was using DataModel for both lines and columns (JSP/Myfaces project, before Seam), isRowAvailable() and getRowData() used to handle increment neatly.
Am I missing something here ?
BTW, a portion of code from my backing beanpublic CELLOBJECT getCellValue(){ DataModel lineDataModel = getLineDataModel(); if (lineDataModel.isRowAvailable()) { Line line = (Line) lineDataModel.getRowData(); if(compteurColonnes >= this.getColumnList().size()){ compteurColonnes = 0; } for (Iterator<Cell<CELLOBJECT>> it = line.getCellList().iterator(); it.hasNext();) { Cell<CELLOBJECT> cell = it.next(); if (cell.getColumnId() == compteurColonnes) { System.out.println("[ " + cell.getLineId() + " , " + cell.getColumnId() + " ] = " + cell.getCellValue().toString()); compteurColonnes++; return cell.getCellValue(); } } } return cellValue; }
-
3. Re: c:forEach and h:column
limousyf Jul 27, 2007 5:04 AM (in response to limousyf)Ok, I'm upping a little this post cause this still doesn't work (arg!).
I tried a simplier solution using the [] operator in the JSF.
It looks like this :<h:dataTable value="#{TestCrossDataTable.boiteNoireSimple.lineDataModel}" var="lineSimple"> <c:forEach items="#{TestCrossDataTable.boiteNoireSimple.columnDataModel.wrappedData}" var="columnSimple"> <h:column> <f:facet name="header"> <h:outputText value="#{columnSimple.columnDesignation}" /> </f:facet> <h:inputText value="#{lineSimple.cellList[columnSimple.columnId].cellValue.jourSaisieValeur}" converter="javax.faces.Double"> </h:inputText> </h:column> </c:forEach> </h:dataTable>
I thought it could save my life but no :/
I can iterate normally over cells, and make my dynamic columns, but I still can access ONE TIME only the cell.
And I need to access multiple times the object in the cell ... -
4. Re: c:forEach and h:column
pmuir Aug 2, 2007 5:58 AM (in response to limousyf)Yes, that last code snippet looks correct. Can you explain in more detail whats going wrong with it.