You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Enrique Medina <e....@gmail.com> on 2005/11/07 20:56:10 UTC

Datasheet with different number of columns per row

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?

Re: Datasheet with different number of columns per row

Posted by Mike Kienenberger <mk...@gmail.com>.
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 <mk...@gmail.com> 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 <e....@gmail.com> 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 <mk...@gmail.com>:
> > > 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 <e....@gmail.com> 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 < mkienenb@gmail.com>:
> > > > > 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 < e.medina.m@gmail.com> 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?
> > > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>

Re: Datasheet with different number of columns per row

Posted by Mike Kienenberger <mk...@gmail.com>.
Well, there has to be some kind of ordering for the data to be
displayed.   It's just a matter of making your column model represent
that ordering, and allowing your row to interpret that ordering.

Remember that a column represents a "class" of data, not an "instance"
of data, so you can't have a separate model for every row.   If you
want to do that, then you'll need to go back to using t:dataList and
implement your own t:columns-like object.

On 11/8/05, Enrique Medina <e....@gmail.com> wrote:
> Put it another way...
>
>  It would be nice to be able to put a data model for the <t:columns> tag for
> each row, but as only it can be set once, how can I define an id reference
> to any of the child objects?
>
> 2005/11/8, Enrique Medina <e....@gmail.com>:
> > The problem here is that my collection is a set, but as I can only specify
> once in the value of the <t:columns> tag the data model, I can't see how can
> I get the exact identifier of the child object being modified.
> >
> > I mean, I only have one data model to populate the <t:columns>, but
> elements in each child collection of each row have distinct identifiers...
> >
> >
> >
> > 2005/11/8, Mike Kienenberger < mkienenb@gmail.com>:
> > > There's no right answer; there are many solutions.  It just has to be
> > > something that you can use to look up the column value for the row
> > > object.
> > >
> > > From what you've said before, one possibility is to use a column data
> > > model that contains the Integers 0 to 7 (or MaxPrivs-1).
> > >
> > > Then you can use
> > >
> > > Object row = rowDataModel.getRowData()
> > > Number indexNumber =
> (Number)columnDataModel.getRowData()
> > > Object row.columnValueAtIndex (indexNumber);
> > >
> > > On 11/8/05, Enrique Medina <e....@gmail.com> wrote:
> > > > I understand, but there is still something I cannot see...
> > > >
> > > >  You use a data model as value to the <t:columns> tag, and then that
> data
> > > > model is used to identify the column selected. So my question is: what
> kind
> > > > of data model should I use so later any of my child objects can be
> > > > identified?
> > > >
> > > > 2005/11/8, Mike Kienenberger < mkienenb@gmail.com>:
> > > > > In my example, the columns were independent of the rows.
> > > > >
> > > > > In your case, you'll have to first compute the maximum size.
> > > > >
> > > > > Using my code, I'd do it something like this:
> > > > >
> > > > > ==============
> > > > > private columnList = null;
> > > > >
> > > > > public List getColumnList()  {
> > > > >       if (null == columnList) {
> > > > >           List rowList = getRowList();
> > > > >           // iterate over the row list and determine the value for
> > > > > maxColumnCount
> > > > >           columnList =
> > > > createColumnListOfSize(maxColumnCount);
> > > > >       }
> > > > >
> > > > >       return columnList;
> > > > > }
> > > > >
> > > > > public boolean getValueFor(Object rowObject, Object columnObject) {
> > > > >       int columnIndex = columnObject.findIndex ();
> > > > >       if (columnIndex >= rowObject.getColumnList.size ())  return
> > > > emptyObject;
> > > > >       else return rowObject.getColumnList(columnIndex);
> > > > > }
> > > > > ==============
> > > > >
> > > > > Obviously, my model isn't a direct fit to what you're doing, but the
> > > > > basic logic is still the same.   The first time you need it, compute
> > > > > the max-size column list.   Then each time a row/column item is
> > > > > accessed, return the column in the row if the row has that many
> > > > > elements, or return an empty object if it doesn't.
> > > > >
> > > > > -Mike
> > > > >
> > > > > On 11/7/05, Enrique Medina < e.medina.m@gmail.com> wrote:
> > > > > > But what should I use in my example as "value" in the <t:columns>
> tag? I
> > > > > > mean, how can I ensure that for each row each of the child objects
> will
> > > > be
> > > > > > called? How does JSF knows it?
> > > > > >
> > > > > >
> > > > > > 2005/11/7, Mike Kienenberger < mkienenb@gmail.com>:
> > > > > > > My suggestion would be to adjust your column model so it always
> has 8
> > > > > > > (or MAX) values for each row, and simply return "empty"
> (whatever that
> > > > > > > means in your component) data for the remaining values.
> > > > > > >
> > > > > > > Alternatively, you could try:
> > > > > > >
> > > > > > > <t:columns>
> > > > > > >   <h:panelgroup>
> > > > > > >     <UIInput rendered="#{!column.empty}">
> > > > > > >     <h:outputText value="" rendered="#{ column.empty }">
> > > > > > >   </h:panelgroup>
> > > > > > > </t:columns>
> > > > > > >
> > > > > > > On 11/7/05, Enrique Medina < e.medina.m@gmail.com> wrote:
> > > > > > > > Just to clarify with a concrete example:
> > > > > > > >
> > > > > > > >  Imagine in your example of users and privileges that you want
> to
> > > > show
> > > > > > as
> > > > > > > > rows the users' names, and as columns simply each user's
> privileges,
> > > > but
> > > > > > the
> > > > > > > > first user (row) has 3 privileges, the second one has 5, the
> third
> > > > one
> > > > > > has 8
> > > > > > > > and the fourth one has 2. The maximum columns will be 8 (as of
> the
> > > > max
> > > > > > > > number of privileges per user), but not all the columns in all
> the
> > > > rows
> > > > > > will
> > > > > > > > be printed...
> > > > > > > >
> > > > > > > > 2005/11/7, Enrique Medina < e.medina.m@gmail.com >:
> > > > > > > > > Great approach!
> > > > > > > > >
> > > > > > > > > Just one comment: while your dynamic number of columns
> > > > > > (allPrivilegeList)
> > > > > > > > is known, mine is not known, and depends as commented before
> on the
> > > > > > maximum
> > > > > > > > size of the collections of the parent objects. For example, in
> your
> > > > > > example,
> > > > > > > > instead of showing all the possible values of the privileges
> as
> > > > column
> > > > > > > > headers and then showing whether the user has the privilege or
> not,
> > > > > > imagine
> > > > > > > > my approach: you need to have as many columns as the maximum
> > > > elements in
> > > > > > any
> > > > > > > > of the collections of the parent objects that populate the
> data
> > > > table.
> > > > > > > > >
> > > > > > > > > Do you know what I mean?
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > 2005/11/7, Mike Kienenberger < mkienenb@gmail.com >:
> > > > > > > > > > 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 < e.medina.m@gmail.com> 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 < mkienenb@gmail.com>:
> > > > > > > > > > > > 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 < e.medina.m@gmail.com >
> 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 < mkienenb@gmail.com>:
> > > > > > > > > > > > > > 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 < e.medina.m@gmail.com
> >
> > > > 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?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>
>

Re: Datasheet with different number of columns per row

Posted by Enrique Medina <e....@gmail.com>.
Put it another way...

It would be nice to be able to put a data model for the <t:columns> tag for
each row, but as only it can be set once, how can I define an id reference
to any of the child objects?

2005/11/8, Enrique Medina <e....@gmail.com>:
>
> The problem here is that my collection is a set, but as I can only specify
> once in the value of the <t:columns> tag the data model, I can't see how can
> I get the exact identifier of the child object being modified.
>
> I mean, I only have one data model to populate the <t:columns>, but
> elements in each child collection of each row have distinct identifiers...
>
> 2005/11/8, Mike Kienenberger <mk...@gmail.com>:
> >
> > There's no right answer; there are many solutions. It just has to be
> > something that you can use to look up the column value for the row
> > object.
> >
> > From what you've said before, one possibility is to use a column data
> > model that contains the Integers 0 to 7 (or MaxPrivs-1).
> >
> > Then you can use
> >
> > Object row = rowDataModel.getRowData()
> > Number indexNumber = (Number)columnDataModel.getRowData()
> > Object row.columnValueAtIndex (indexNumber);
> >
> > On 11/8/05, Enrique Medina <e....@gmail.com> wrote:
> > > I understand, but there is still something I cannot see...
> > >
> > > You use a data model as value to the <t:columns> tag, and then that
> > data
> > > model is used to identify the column selected. So my question is: what
> > kind
> > > of data model should I use so later any of my child objects can be
> > > identified?
> > >
> > > 2005/11/8, Mike Kienenberger < mkienenb@gmail.com>:
> > > > In my example, the columns were independent of the rows.
> > > >
> > > > In your case, you'll have to first compute the maximum size.
> > > >
> > > > Using my code, I'd do it something like this:
> > > >
> > > > ==============
> > > > private columnList = null;
> > > >
> > > > public List getColumnList() {
> > > > if (null == columnList) {
> > > > List rowList = getRowList();
> > > > // iterate over the row list and determine the value for
> > > > maxColumnCount
> > > > columnList =
> > > createColumnListOfSize(maxColumnCount);
> > > > }
> > > >
> > > > return columnList;
> > > > }
> > > >
> > > > public boolean getValueFor(Object rowObject, Object columnObject) {
> > > > int columnIndex = columnObject.findIndex ();
> > > > if (columnIndex >= rowObject.getColumnList.size ()) return
> > > emptyObject;
> > > > else return rowObject.getColumnList(columnIndex);
> > > > }
> > > > ==============
> > > >
> > > > Obviously, my model isn't a direct fit to what you're doing, but the
> > > > basic logic is still the same. The first time you need it, compute
> > > > the max-size column list. Then each time a row/column item is
> > > > accessed, return the column in the row if the row has that many
> > > > elements, or return an empty object if it doesn't.
> > > >
> > > > -Mike
> > > >
> > > > On 11/7/05, Enrique Medina < e.medina.m@gmail.com> wrote:
> > > > > But what should I use in my example as "value" in the <t:columns>
> > tag? I
> > > > > mean, how can I ensure that for each row each of the child objects
> > will
> > > be
> > > > > called? How does JSF knows it?
> > > > >
> > > > >
> > > > > 2005/11/7, Mike Kienenberger <mk...@gmail.com>:
> > > > > > My suggestion would be to adjust your column model so it always
> > has 8
> > > > > > (or MAX) values for each row, and simply return "empty"
> > (whatever that
> > > > > > means in your component) data for the remaining values.
> > > > > >
> > > > > > Alternatively, you could try:
> > > > > >
> > > > > > <t:columns>
> > > > > > <h:panelgroup>
> > > > > > <UIInput rendered="#{!column.empty}">
> > > > > > <h:outputText value="" rendered="#{ column.empty }">
> > > > > > </h:panelgroup>
> > > > > > </t:columns>
> > > > > >
> > > > > > On 11/7/05, Enrique Medina < e.medina.m@gmail.com> wrote:
> > > > > > > Just to clarify with a concrete example:
> > > > > > >
> > > > > > > Imagine in your example of users and privileges that you want
> > to
> > > show
> > > > > as
> > > > > > > rows the users' names, and as columns simply each user's
> > privileges,
> > > but
> > > > > the
> > > > > > > first user (row) has 3 privileges, the second one has 5, the
> > third
> > > one
> > > > > has 8
> > > > > > > and the fourth one has 2. The maximum columns will be 8 (as of
> > the
> > > max
> > > > > > > number of privileges per user), but not all the columns in all
> > the
> > > rows
> > > > > will
> > > > > > > be printed...
> > > > > > >
> > > > > > > 2005/11/7, Enrique Medina <e.medina.m@gmail.com >:
> > > > > > > > Great approach!
> > > > > > > >
> > > > > > > > Just one comment: while your dynamic number of columns
> > > > > (allPrivilegeList)
> > > > > > > is known, mine is not known, and depends as commented before
> > on the
> > > > > maximum
> > > > > > > size of the collections of the parent objects. For example, in
> > your
> > > > > example,
> > > > > > > instead of showing all the possible values of the privileges
> > as
> > > column
> > > > > > > headers and then showing whether the user has the privilege or
> > not,
> > > > > imagine
> > > > > > > my approach: you need to have as many columns as the maximum
> > > elements in
> > > > > any
> > > > > > > of the collections of the parent objects that populate the
> > data
> > > table.
> > > > > > > >
> > > > > > > > Do you know what I mean?
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > 2005/11/7, Mike Kienenberger < mkienenb@gmail.com >:
> > > > > > > > > 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 < e.medina.m@gmail.com> 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 < mkienenb@gmail.com>:
> > > > > > > > > > > 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 < e.medina.m@gmail.com >
> > 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 < mkienenb@gmail.com>:
> > > > > > > > > > > > > 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 < e.medina.m@gmail.com>
> > > 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?
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> > >
> >
>
>

Re: Datasheet with different number of columns per row

Posted by Enrique Medina <e....@gmail.com>.
The problem here is that my collection is a set, but as I can only specify
once in the value of the <t:columns> tag the data model, I can't see how can
I get the exact identifier of the child object being modified.

I mean, I only have one data model to populate the <t:columns>, but elements
in each child collection of each row have distinct identifiers...

2005/11/8, Mike Kienenberger <mk...@gmail.com>:
>
> There's no right answer; there are many solutions. It just has to be
> something that you can use to look up the column value for the row
> object.
>
> From what you've said before, one possibility is to use a column data
> model that contains the Integers 0 to 7 (or MaxPrivs-1).
>
> Then you can use
>
> Object row = rowDataModel.getRowData()
> Number indexNumber = (Number)columnDataModel.getRowData()
> Object row.columnValueAtIndex(indexNumber);
>
> On 11/8/05, Enrique Medina <e....@gmail.com> wrote:
> > I understand, but there is still something I cannot see...
> >
> > You use a data model as value to the <t:columns> tag, and then that data
> > model is used to identify the column selected. So my question is: what
> kind
> > of data model should I use so later any of my child objects can be
> > identified?
> >
> > 2005/11/8, Mike Kienenberger <mk...@gmail.com>:
> > > In my example, the columns were independent of the rows.
> > >
> > > In your case, you'll have to first compute the maximum size.
> > >
> > > Using my code, I'd do it something like this:
> > >
> > > ==============
> > > private columnList = null;
> > >
> > > public List getColumnList() {
> > > if (null == columnList) {
> > > List rowList = getRowList();
> > > // iterate over the row list and determine the value for
> > > maxColumnCount
> > > columnList =
> > createColumnListOfSize(maxColumnCount);
> > > }
> > >
> > > return columnList;
> > > }
> > >
> > > public boolean getValueFor(Object rowObject, Object columnObject) {
> > > int columnIndex = columnObject.findIndex();
> > > if (columnIndex >= rowObject.getColumnList.size ()) return
> > emptyObject;
> > > else return rowObject.getColumnList(columnIndex);
> > > }
> > > ==============
> > >
> > > Obviously, my model isn't a direct fit to what you're doing, but the
> > > basic logic is still the same. The first time you need it, compute
> > > the max-size column list. Then each time a row/column item is
> > > accessed, return the column in the row if the row has that many
> > > elements, or return an empty object if it doesn't.
> > >
> > > -Mike
> > >
> > > On 11/7/05, Enrique Medina < e.medina.m@gmail.com> wrote:
> > > > But what should I use in my example as "value" in the <t:columns>
> tag? I
> > > > mean, how can I ensure that for each row each of the child objects
> will
> > be
> > > > called? How does JSF knows it?
> > > >
> > > >
> > > > 2005/11/7, Mike Kienenberger <mk...@gmail.com>:
> > > > > My suggestion would be to adjust your column model so it always
> has 8
> > > > > (or MAX) values for each row, and simply return "empty" (whatever
> that
> > > > > means in your component) data for the remaining values.
> > > > >
> > > > > Alternatively, you could try:
> > > > >
> > > > > <t:columns>
> > > > > <h:panelgroup>
> > > > > <UIInput rendered="#{!column.empty}">
> > > > > <h:outputText value="" rendered="#{column.empty }">
> > > > > </h:panelgroup>
> > > > > </t:columns>
> > > > >
> > > > > On 11/7/05, Enrique Medina <e....@gmail.com> wrote:
> > > > > > Just to clarify with a concrete example:
> > > > > >
> > > > > > Imagine in your example of users and privileges that you want to
> > show
> > > > as
> > > > > > rows the users' names, and as columns simply each user's
> privileges,
> > but
> > > > the
> > > > > > first user (row) has 3 privileges, the second one has 5, the
> third
> > one
> > > > has 8
> > > > > > and the fourth one has 2. The maximum columns will be 8 (as of
> the
> > max
> > > > > > number of privileges per user), but not all the columns in all
> the
> > rows
> > > > will
> > > > > > be printed...
> > > > > >
> > > > > > 2005/11/7, Enrique Medina <e....@gmail.com>:
> > > > > > > Great approach!
> > > > > > >
> > > > > > > Just one comment: while your dynamic number of columns
> > > > (allPrivilegeList)
> > > > > > is known, mine is not known, and depends as commented before on
> the
> > > > maximum
> > > > > > size of the collections of the parent objects. For example, in
> your
> > > > example,
> > > > > > instead of showing all the possible values of the privileges as
> > column
> > > > > > headers and then showing whether the user has the privilege or
> not,
> > > > imagine
> > > > > > my approach: you need to have as many columns as the maximum
> > elements in
> > > > any
> > > > > > of the collections of the parent objects that populate the data
> > table.
> > > > > > >
> > > > > > > Do you know what I mean?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > 2005/11/7, Mike Kienenberger < mkienenb@gmail.com >:
> > > > > > > > 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 < e.medina.m@gmail.com> 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 < mkienenb@gmail.com>:
> > > > > > > > > > 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 < e.medina.m@gmail.com >
> 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 < mkienenb@gmail.com>:
> > > > > > > > > > > > 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 < e.medina.m@gmail.com >
> > 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?
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>

Re: Datasheet with different number of columns per row

Posted by Mike Kienenberger <mk...@gmail.com>.
There's no right answer; there are many solutions.  It just has to be
something that you can use to look up the column value for the row
object.

>From what you've said before, one possibility is to use a column data
model that contains the Integers 0 to 7 (or MaxPrivs-1).

Then you can use

Object row = rowDataModel.getRowData()
Number indexNumber = (Number)columnDataModel.getRowData()
Object row.columnValueAtIndex(indexNumber);

On 11/8/05, Enrique Medina <e....@gmail.com> wrote:
> I understand, but there is still something I cannot see...
>
>  You use a data model as value to the <t:columns> tag, and then that data
> model is used to identify the column selected. So my question is: what kind
> of data model should I use so later any of my child objects can be
> identified?
>
> 2005/11/8, Mike Kienenberger <mk...@gmail.com>:
> > In my example, the columns were independent of the rows.
> >
> > In your case, you'll have to first compute the maximum size.
> >
> > Using my code, I'd do it something like this:
> >
> > ==============
> > private columnList = null;
> >
> > public List getColumnList()  {
> >       if (null == columnList) {
> >           List rowList = getRowList();
> >           // iterate over the row list and determine the value for
> > maxColumnCount
> >           columnList =
> createColumnListOfSize(maxColumnCount);
> >       }
> >
> >       return columnList;
> > }
> >
> > public boolean getValueFor(Object rowObject, Object columnObject) {
> >       int columnIndex = columnObject.findIndex();
> >       if (columnIndex >= rowObject.getColumnList.size ())  return
> emptyObject;
> >       else return rowObject.getColumnList(columnIndex);
> > }
> > ==============
> >
> > Obviously, my model isn't a direct fit to what you're doing, but the
> > basic logic is still the same.   The first time you need it, compute
> > the max-size column list.   Then each time a row/column item is
> > accessed, return the column in the row if the row has that many
> > elements, or return an empty object if it doesn't.
> >
> > -Mike
> >
> > On 11/7/05, Enrique Medina < e.medina.m@gmail.com> wrote:
> > > But what should I use in my example as "value" in the <t:columns> tag? I
> > > mean, how can I ensure that for each row each of the child objects will
> be
> > > called? How does JSF knows it?
> > >
> > >
> > > 2005/11/7, Mike Kienenberger <mk...@gmail.com>:
> > > > My suggestion would be to adjust your column model so it always has 8
> > > > (or MAX) values for each row, and simply return "empty" (whatever that
> > > > means in your component) data for the remaining values.
> > > >
> > > > Alternatively, you could try:
> > > >
> > > > <t:columns>
> > > >   <h:panelgroup>
> > > >     <UIInput rendered="#{!column.empty}">
> > > >     <h:outputText value="" rendered="#{column.empty }">
> > > >   </h:panelgroup>
> > > > </t:columns>
> > > >
> > > > On 11/7/05, Enrique Medina <e....@gmail.com> wrote:
> > > > > Just to clarify with a concrete example:
> > > > >
> > > > >  Imagine in your example of users and privileges that you want to
> show
> > > as
> > > > > rows the users' names, and as columns simply each user's privileges,
> but
> > > the
> > > > > first user (row) has 3 privileges, the second one has 5, the third
> one
> > > has 8
> > > > > and the fourth one has 2. The maximum columns will be 8 (as of the
> max
> > > > > number of privileges per user), but not all the columns in all the
> rows
> > > will
> > > > > be printed...
> > > > >
> > > > > 2005/11/7, Enrique Medina <e....@gmail.com>:
> > > > > > Great approach!
> > > > > >
> > > > > > Just one comment: while your dynamic number of columns
> > > (allPrivilegeList)
> > > > > is known, mine is not known, and depends as commented before on the
> > > maximum
> > > > > size of the collections of the parent objects. For example, in your
> > > example,
> > > > > instead of showing all the possible values of the privileges as
> column
> > > > > headers and then showing whether the user has the privilege or not,
> > > imagine
> > > > > my approach: you need to have as many columns as the maximum
> elements in
> > > any
> > > > > of the collections of the parent objects that populate the data
> table.
> > > > > >
> > > > > > Do you know what I mean?
> > > > > >
> > > > > >
> > > > > >
> > > > > > 2005/11/7, Mike Kienenberger < mkienenb@gmail.com >:
> > > > > > > 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 < e.medina.m@gmail.com> 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 < mkienenb@gmail.com>:
> > > > > > > > > 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 < e.medina.m@gmail.com > 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 < mkienenb@gmail.com>:
> > > > > > > > > > > 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 < e.medina.m@gmail.com >
> 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?
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> > >
> >
>
>

Re: Datasheet with different number of columns per row

Posted by Enrique Medina <e....@gmail.com>.
I understand, but there is still something I cannot see...

You use a data model as value to the <t:columns> tag, and then that data
model is used to identify the column selected. So my question is: what kind
of data model should I use so later any of my child objects can be
identified?

2005/11/8, Mike Kienenberger <mk...@gmail.com>:
>
> In my example, the columns were independent of the rows.
>
> In your case, you'll have to first compute the maximum size.
>
> Using my code, I'd do it something like this:
>
> ==============
> private columnList = null;
>
> public List getColumnList() {
> if (null == columnList) {
> List rowList = getRowList();
> // iterate over the row list and determine the value for
> maxColumnCount
> columnList = createColumnListOfSize(maxColumnCount);
> }
>
> return columnList;
> }
>
> public boolean getValueFor(Object rowObject, Object columnObject) {
> int columnIndex = columnObject.findIndex();
> if (columnIndex >= rowObject.getColumnList.size()) return emptyObject;
> else return rowObject.getColumnList(columnIndex);
> }
> ==============
>
> Obviously, my model isn't a direct fit to what you're doing, but the
> basic logic is still the same. The first time you need it, compute
> the max-size column list. Then each time a row/column item is
> accessed, return the column in the row if the row has that many
> elements, or return an empty object if it doesn't.
>
> -Mike
>
> On 11/7/05, Enrique Medina <e....@gmail.com> wrote:
> > But what should I use in my example as "value" in the <t:columns> tag? I
> > mean, how can I ensure that for each row each of the child objects will
> be
> > called? How does JSF knows it?
> >
> >
> > 2005/11/7, Mike Kienenberger <mk...@gmail.com>:
> > > My suggestion would be to adjust your column model so it always has 8
> > > (or MAX) values for each row, and simply return "empty" (whatever that
> > > means in your component) data for the remaining values.
> > >
> > > Alternatively, you could try:
> > >
> > > <t:columns>
> > > <h:panelgroup>
> > > <UIInput rendered="#{!column.empty}">
> > > <h:outputText value="" rendered="#{column.empty}">
> > > </h:panelgroup>
> > > </t:columns>
> > >
> > > On 11/7/05, Enrique Medina <e....@gmail.com> wrote:
> > > > Just to clarify with a concrete example:
> > > >
> > > > Imagine in your example of users and privileges that you want to
> show
> > as
> > > > rows the users' names, and as columns simply each user's privileges,
> but
> > the
> > > > first user (row) has 3 privileges, the second one has 5, the third
> one
> > has 8
> > > > and the fourth one has 2. The maximum columns will be 8 (as of the
> max
> > > > number of privileges per user), but not all the columns in all the
> rows
> > will
> > > > be printed...
> > > >
> > > > 2005/11/7, Enrique Medina <e....@gmail.com>:
> > > > > Great approach!
> > > > >
> > > > > Just one comment: while your dynamic number of columns
> > (allPrivilegeList)
> > > > is known, mine is not known, and depends as commented before on the
> > maximum
> > > > size of the collections of the parent objects. For example, in your
> > example,
> > > > instead of showing all the possible values of the privileges as
> column
> > > > headers and then showing whether the user has the privilege or not,
> > imagine
> > > > my approach: you need to have as many columns as the maximum
> elements in
> > any
> > > > of the collections of the parent objects that populate the data
> table.
> > > > >
> > > > > Do you know what I mean?
> > > > >
> > > > >
> > > > >
> > > > > 2005/11/7, Mike Kienenberger < mkienenb@gmail.com>:
> > > > > > 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 < e.medina.m@gmail.com> 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 < mkienenb@gmail.com>:
> > > > > > > > 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 < e.medina.m@gmail.com > 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 < mkienenb@gmail.com>:
> > > > > > > > > > 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 < e.medina.m@gmail.com >
> 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?
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>

Re: Datasheet with different number of columns per row

Posted by Mike Kienenberger <mk...@gmail.com>.
In my example, the columns were independent of the rows.

In your case, you'll have to first compute the maximum size.

Using my code, I'd do it something like this:

==============
private columnList = null;

public List getColumnList()  {
      if (null == columnList) {
          List rowList = getRowList();
          // iterate over the row list and determine the value for
maxColumnCount
          columnList = createColumnListOfSize(maxColumnCount);
      }

      return columnList;
}

public boolean getValueFor(Object rowObject, Object columnObject) {
      int columnIndex = columnObject.findIndex();
      if (columnIndex >= rowObject.getColumnList.size())  return emptyObject;
      else return rowObject.getColumnList(columnIndex);
}
==============

Obviously, my model isn't a direct fit to what you're doing, but the
basic logic is still the same.   The first time you need it, compute
the max-size column list.   Then each time a row/column item is
accessed, return the column in the row if the row has that many
elements, or return an empty object if it doesn't.

-Mike

On 11/7/05, Enrique Medina <e....@gmail.com> wrote:
> But what should I use in my example as "value" in the <t:columns> tag? I
> mean, how can I ensure that for each row each of the child objects will be
> called? How does JSF knows it?
>
>
> 2005/11/7, Mike Kienenberger <mk...@gmail.com>:
> > My suggestion would be to adjust your column model so it always has 8
> > (or MAX) values for each row, and simply return "empty" (whatever that
> > means in your component) data for the remaining values.
> >
> > Alternatively, you could try:
> >
> > <t:columns>
> >   <h:panelgroup>
> >     <UIInput rendered="#{!column.empty}">
> >     <h:outputText value="" rendered="#{column.empty}">
> >   </h:panelgroup>
> > </t:columns>
> >
> > On 11/7/05, Enrique Medina <e....@gmail.com> wrote:
> > > Just to clarify with a concrete example:
> > >
> > >  Imagine in your example of users and privileges that you want to show
> as
> > > rows the users' names, and as columns simply each user's privileges, but
> the
> > > first user (row) has 3 privileges, the second one has 5, the third one
> has 8
> > > and the fourth one has 2. The maximum columns will be 8 (as of the max
> > > number of privileges per user), but not all the columns in all the rows
> will
> > > be printed...
> > >
> > > 2005/11/7, Enrique Medina <e....@gmail.com>:
> > > > Great approach!
> > > >
> > > > Just one comment: while your dynamic number of columns
> (allPrivilegeList)
> > > is known, mine is not known, and depends as commented before on the
> maximum
> > > size of the collections of the parent objects. For example, in your
> example,
> > > instead of showing all the possible values of the privileges as column
> > > headers and then showing whether the user has the privilege or not,
> imagine
> > > my approach: you need to have as many columns as the maximum elements in
> any
> > > of the collections of the parent objects that populate the data table.
> > > >
> > > > Do you know what I mean?
> > > >
> > > >
> > > >
> > > > 2005/11/7, Mike Kienenberger < mkienenb@gmail.com>:
> > > > > 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 < e.medina.m@gmail.com> 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 < mkienenb@gmail.com>:
> > > > > > > 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 < e.medina.m@gmail.com > 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 < mkienenb@gmail.com>:
> > > > > > > > > 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 < e.medina.m@gmail.com > 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?
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
>
>

Re: Datasheet with different number of columns per row

Posted by Enrique Medina <e....@gmail.com>.
Any comments about my last email regarding this issue? I'm still busy with
it...

Thanks.

2005/11/7, Enrique Medina <e....@gmail.com>:
>
> But what should I use in my example as "value" in the <t:columns> tag? I
> mean, how can I ensure that for each row each of the child objects will be
> called? How does JSF knows it?
>
> 2005/11/7, Mike Kienenberger <mk...@gmail.com>:
> >
> > My suggestion would be to adjust your column model so it always has 8
> > (or MAX) values for each row, and simply return "empty" (whatever that
> > means in your component) data for the remaining values.
> >
> > Alternatively, you could try:
> >
> > <t:columns>
> > <h:panelgroup>
> > <UIInput rendered="#{!column.empty}">
> > <h:outputText value="" rendered="#{column.empty}">
> > </h:panelgroup>
> > </t:columns>
> >
> > On 11/7/05, Enrique Medina <e....@gmail.com> wrote:
> > > Just to clarify with a concrete example:
> > >
> > > Imagine in your example of users and privileges that you want to show
> > as
> > > rows the users' names, and as columns simply each user's privileges,
> > but the
> > > first user (row) has 3 privileges, the second one has 5, the third one
> > has 8
> > > and the fourth one has 2. The maximum columns will be 8 (as of the max
> >
> > > number of privileges per user), but not all the columns in all the
> > rows will
> > > be printed...
> > >
> > > 2005/11/7, Enrique Medina <e....@gmail.com>:
> > > > Great approach!
> > > >
> > > > Just one comment: while your dynamic number of columns
> > (allPrivilegeList)
> > > is known, mine is not known, and depends as commented before on the
> > maximum
> > > size of the collections of the parent objects. For example, in your
> > example,
> > > instead of showing all the possible values of the privileges as column
> > > headers and then showing whether the user has the privilege or not,
> > imagine
> > > my approach: you need to have as many columns as the maximum elements
> > in any
> > > of the collections of the parent objects that populate the data table.
> > > >
> > > > Do you know what I mean?
> > > >
> > > >
> > > >
> > > > 2005/11/7, Mike Kienenberger < mkienenb@gmail.com>:
> > > > > 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 < e.medina.m@gmail.com> 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 < mkienenb@gmail.com>:
> > > > > > > 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 < e.medina.m@gmail.com > 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 < mkienenb@gmail.com>:
> > > > > > > > > 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 < e.medina.m@gmail.com > 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?
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
>
>

Re: Datasheet with different number of columns per row

Posted by Enrique Medina <e....@gmail.com>.
But what should I use in my example as "value" in the <t:columns> tag? I
mean, how can I ensure that for each row each of the child objects will be
called? How does JSF knows it?

2005/11/7, Mike Kienenberger <mk...@gmail.com>:
>
> My suggestion would be to adjust your column model so it always has 8
> (or MAX) values for each row, and simply return "empty" (whatever that
> means in your component) data for the remaining values.
>
> Alternatively, you could try:
>
> <t:columns>
> <h:panelgroup>
> <UIInput rendered="#{!column.empty}">
> <h:outputText value="" rendered="#{column.empty}">
> </h:panelgroup>
> </t:columns>
>
> On 11/7/05, Enrique Medina <e....@gmail.com> wrote:
> > Just to clarify with a concrete example:
> >
> > Imagine in your example of users and privileges that you want to show as
> > rows the users' names, and as columns simply each user's privileges, but
> the
> > first user (row) has 3 privileges, the second one has 5, the third one
> has 8
> > and the fourth one has 2. The maximum columns will be 8 (as of the max
> > number of privileges per user), but not all the columns in all the rows
> will
> > be printed...
> >
> > 2005/11/7, Enrique Medina <e....@gmail.com>:
> > > Great approach!
> > >
> > > Just one comment: while your dynamic number of columns
> (allPrivilegeList)
> > is known, mine is not known, and depends as commented before on the
> maximum
> > size of the collections of the parent objects. For example, in your
> example,
> > instead of showing all the possible values of the privileges as column
> > headers and then showing whether the user has the privilege or not,
> imagine
> > my approach: you need to have as many columns as the maximum elements in
> any
> > of the collections of the parent objects that populate the data table.
> > >
> > > Do you know what I mean?
> > >
> > >
> > >
> > > 2005/11/7, Mike Kienenberger < mkienenb@gmail.com>:
> > > > 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 <e....@gmail.com> 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 < mkienenb@gmail.com>:
> > > > > > 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 < e.medina.m@gmail.com > 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 < mkienenb@gmail.com>:
> > > > > > > > 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 < e.medina.m@gmail.com > 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?
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> > >
> >
> >
>

Re: Datasheet with different number of columns per row

Posted by Mike Kienenberger <mk...@gmail.com>.
My suggestion would be to adjust your column model so it always has 8
(or MAX) values for each row, and simply return "empty" (whatever that
means in your component) data for the remaining values.

Alternatively, you could try:

<t:columns>
  <h:panelgroup>
    <UIInput rendered="#{!column.empty}">
    <h:outputText value="" rendered="#{column.empty}">
  </h:panelgroup>
</t:columns>

On 11/7/05, Enrique Medina <e....@gmail.com> wrote:
> Just to clarify with a concrete example:
>
>  Imagine in your example of users and privileges that you want to show as
> rows the users' names, and as columns simply each user's privileges, but the
> first user (row) has 3 privileges, the second one has 5, the third one has 8
> and the fourth one has 2. The maximum columns will be 8 (as of the max
> number of privileges per user), but not all the columns in all the rows will
> be printed...
>
> 2005/11/7, Enrique Medina <e....@gmail.com>:
> > Great approach!
> >
> > Just one comment: while your dynamic number of columns (allPrivilegeList)
> is known, mine is not known, and depends as commented before on the maximum
> size of the collections of the parent objects. For example, in your example,
> instead of showing all the possible values of the privileges as column
> headers and then showing whether the user has the privilege or not, imagine
> my approach: you need to have as many columns as the maximum elements in any
> of the collections of the parent objects that populate the data table.
> >
> > Do you know what I mean?
> >
> >
> >
> > 2005/11/7, Mike Kienenberger < mkienenb@gmail.com>:
> > > 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 <e....@gmail.com> 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 < mkienenb@gmail.com>:
> > > > > 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 < e.medina.m@gmail.com > 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 < mkienenb@gmail.com>:
> > > > > > > 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 < e.medina.m@gmail.com > 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?
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>
>

Re: Datasheet with different number of columns per row

Posted by Enrique Medina <e....@gmail.com>.
Just to clarify with a concrete example:

Imagine in your example of users and privileges that you want to show as
rows the users' names, and as columns simply each user's privileges, but the
first user (row) has 3 privileges, the second one has 5, the third one has 8
and the fourth one has 2. The maximum columns will be 8 (as of the max
number of privileges per user), but not all the columns in all the rows will
be printed...

2005/11/7, Enrique Medina <e....@gmail.com>:
>
> Great approach!
>
> Just one comment: while your dynamic number of columns (allPrivilegeList)
> is known, mine is not known, and depends as commented before on the maximum
> size of the collections of the parent objects. For example, in your example,
> instead of showing all the possible values of the privileges as column
> headers and then showing whether the user has the privilege or not, imagine
> my approach: you need to have as many columns as the maximum elements in any
> of the collections of the parent objects that populate the data table.
>
> Do you know what I mean?
>
> 2005/11/7, Mike Kienenberger <mk...@gmail.com>:
> >
> > 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 <e....@gmail.com> 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 <mk...@gmail.com>:
> > > > 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 <e.medina.m@gmail.com > 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 < mkienenb@gmail.com>:
> > > > > > 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 < e.medina.m@gmail.com > 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?
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> > >
> >
>
>

Re: Datasheet with different number of columns per row

Posted by Enrique Medina <e....@gmail.com>.
Great approach!

Just one comment: while your dynamic number of columns (allPrivilegeList) is
known, mine is not known, and depends as commented before on the maximum
size of the collections of the parent objects. For example, in your example,
instead of showing all the possible values of the privileges as column
headers and then showing whether the user has the privilege or not, imagine
my approach: you need to have as many columns as the maximum elements in any
of the collections of the parent objects that populate the data table.

Do you know what I mean?

2005/11/7, Mike Kienenberger <mk...@gmail.com>:
>
> 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 <e....@gmail.com> 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 <mk...@gmail.com>:
> > > 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 <e....@gmail.com> 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 < mkienenb@gmail.com>:
> > > > > 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 < e.medina.m@gmail.com> 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?
> > > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>

Re: Datasheet with different number of columns per row

Posted by Mike Kienenberger <mk...@gmail.com>.
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 <e....@gmail.com> 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 <mk...@gmail.com>:
> > 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 <e....@gmail.com> 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 < mkienenb@gmail.com>:
> > > > 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 < e.medina.m@gmail.com> 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?
> > > > >
> > > >
> > >
> > >
> >
>
>

Re: Datasheet with different number of columns per row

Posted by Enrique Medina <e....@gmail.com>.
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 <mk...@gmail.com>:
>
> 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 <e....@gmail.com> 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 <mk...@gmail.com>:
> > > 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 <e....@gmail.com> 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?
> > > >
> > >
> >
> >
>

Re: Datasheet with different number of columns per row

Posted by Mike Kienenberger <mk...@gmail.com>.
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 <e....@gmail.com> 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 <mk...@gmail.com>:
> > 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 <e....@gmail.com> 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?
> > >
> >
>
>

Re: Datasheet with different number of columns per row

Posted by Enrique Medina <e....@gmail.com>.
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 <mk...@gmail.com>:
>
> 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 <e....@gmail.com> 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?
> >
>

Re: Datasheet with different number of columns per row

Posted by Mike Kienenberger <mk...@gmail.com>.
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 <e....@gmail.com> 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?
>