And I forgot the link -- I hate it when I do that.

http://issues.apache.org/jira/secure/attachment/12311217/RowAndColumnRelationshipComponent.zip

On 11/7/05, Mike Kienenberger <[EMAIL PROTECTED]> wrote:
> I always point out this example code I made as an example of creating
> a composite component, but it also has a good example of using a
> combined row&column data model.
>
> Take a look at RowAndColumnRelationshipsBackingBean which provides the
> row model and the column model.   I then implement the interface in
> RowAndColumnRelationshipsDataModel and can plug any number of models
> into my page.
>
> I no longer use any of the other classes since I've switched over to facelets.
> Instead, I now just use this page code.  I've removed some of the
> decorations (like the dataScrollers), but these three files
> (RowAndColumnRelationshipsBackingBean,
> RowAndColumnRelationshipsDataModel, and the code below) should
> demonstrate it sufficiently.
>
> This level of indirection might be overkill for what you're doing, so
> you might simply rewrite how RowAndColumnRelationshipsBackingBean
> works internally.
>
> "backingBean" is a RowAndColumnRelationshipsBackingBean configured
> with another bean that implements a
> RowAndColumnRelationshipsDataModel.
>
>           <x:dataTable id="datatable"
>                        value="#{backingBean.rowDataModel}"
>                        var="row"
>                        preserveDataModel="false"
>           >
>
>             <f:facet name="footer">
>                 <h:panelGroup>
>                     <h:commandButton value="Update"
> actionListener="#{backingBean.update}"/>
>                 </h:panelGroup>
>             </f:facet>
>             <h:column>
>                 <h:outputText value="#{row.rowName}"/>
>             </h:column>
>             <x:columns
>                 value="#{backingBean.columnDataModel}"
>                 var="column">
>               <f:facet name="header">
>                 <h:outputText value="#{column.columnName}"/>
>               </f:facet>
>               <h:selectBooleanCheckbox
> value="#{backingBean.relationshipValue}"/>
>             </x:columns>
>           </x:dataTable>
>
>
> On 11/7/05, Enrique Medina <[EMAIL PROTECTED]> wrote:
> > I understand Mike :-)
> >
> >  So if I have a collection of parent objects, which in turn each parent
> > object has a collection of other child objects, then I can show a table
> > where the first column is fixed and contains vertically the list of the
> > parent objects, but for each row, the columns are dynamic and can show the
> > collection of child objects for each parent. Is that right?
> >
> >  What should I use for each data model, I mean, the collection of parent
> > objects to populate the main data table and the child collection of each
> > parent object to populate the columns component? Would that make sense? If I
> > edit all the child objects, would the getRowData from the main table return
> > me a parent object with its colllection modified so I could rapidly persist
> > it?
> >
> >  Thanks for your support ;-)
> >
> >
> > 2005/11/7, Mike Kienenberger <[EMAIL PROTECTED]>:
> > > t:columns does exactly that -- it takes a collection of data and makes
> > > as many columns as items in the collection.
> > >
> > > In fact, you can think of t:columns as a data table rotated 90 degrees.
> > > The t:columns component, like dataTable is a subclass of UIData.   The
> > > "trick" is that when t:columns renders a "row" it uses <td> instead of
> > > <tr>.   It's not quite that simple, but from the perspective of an
> > > end-user, it can be treated as such.
> > >
> > > In fact, t:columns API is a little bit confusing since getRowData()
> > > really means getColumnData and getRowIndex() really means
> > > getColumnIndex().   Again, that's because it's effectively a nested
> > > dataTable that renders td tags instead of tr tags.
> > >
> > > I hope that helps!
> > >
> > > On 11/7/05, Enrique Medina <[EMAIL PROTECTED]> wrote:
> > > > Well, maybe I have explained myself badly, but obviously the number of
> > rows,
> > > > although dynamic, would be fixed (i.e. the maximum of all).
> > > >
> > > >  The main problem I have is that the data for the columns is a
> > collection
> > > > rather than a fixed number of properties in a class; i.e . it represents
> > an
> > > > object with a collection of objects inside it, and each element of the
> > > > collection is the data I want to show for every column.
> > > >
> > > > 2005/11/7, Mike Kienenberger < [EMAIL PROTECTED]>:
> > > > > I don't know of a component that generates a different number of
> > > > > columns for each row.   Columns allows a dynamic number of columns,
> > > > > but the number is still the same for every row.
> > > > >
> > > > > What kind of html would you expect it to generate, since a standard
> > > > > html table expects a set number of columns?
> > > > >
> > > > > Probably, your best bet is to go with a t:dataList which operates on
> > > > > row data, but doesn't render any particular output.   Then, for each
> > > > > row, you can output whatever kind of html that you need.
> > > > >
> > > > > On 11/7/05, Enrique Medina < [EMAIL PROTECTED]> wrote:
> > > > > > Hi,
> > > > > >
> > > > > >  I want to create a special data table where the number of columns
> > is
> > > > > > variable in each row depending of the value of the object being
> > painted.
> > > > > >
> > > > > >  I've been looking at the HtmlColumns component, but although being
> > > > dynamic,
> > > > > > I can't see how I can define different number of columns for each
> > row.
> > > > > >
> > > > > >  Any idea of how to accomplish this kind of data sheet?
> > > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>

Reply via email to