On Tue, 2006-01-17 at 21:20 +0100, Andreas Zeller - zit-systems wrote:
> Hi there,
> 
> I have been working with myFaces for the past few weeks and tried to
> implement a product management tool.
> 
> Works as follows:
> 
> It displays and html table with several columns, that should as well be
> removable and movable. I managed to implement sorting with
> commandSortHeader and inline-editing, using the column Tag.

I've implemented exactly that, with a "picklist" popup dialog to allow
the user to select which columns are shown, and in which order.

It's not possible to do this with the standard datatable, however. I
wrote a custom subclass of t:dataTable which adds attribute
"columnOrder". A custom renderer then filters the columns seen by the
standard renderer.

> 
> But I am a little confused using the columns tag. How can I, for
> instance, set a single column not rendered? If I set the rendered
> attribute, I thought it might affect only a single column, but the
> moment I set the rendered attribute, it disable the entire set of columns.

Yep. That approach doesn't work (at least I spent a lot of time on it,
and didn't find any way to just hide a column).

> 
> Anyway, I now decided to remove the columns from the model and remove
> the data instead of disabling them, but somehow I now get an
> IndexOutOfBoundsException that I didn't manage to get rid of yet.

That doesn't work; removing columns has all sorts of nasty internal
implications for the data table component. However a custom Renderer can
effectively do this by overriding the getChildren and getChildCount
methods to "filter out" the unwanted columns.

> 
> My question would be, if anybody already has such a table model as a
> reference. I already took a look at the examples at irian.at, but the
> only dynamic model doesn't actually move and remove columns but fill
> them dynamically with random numbers, not exactly with values.

I've got permission to contribute this code to MyFaces, but not enough
time to do the actual integration just now. I can send you the code,
though.

> 
> If anyone has an example for that, I'd be glad if he or she might want
> to share it with me.

An alternative is to use the t:columns component instead of normal
columns, ie have a table with just one child: a t:columns. This then
allows you to define everything very dynamically though it does move the
definition of what columns exist into the backing bean rather than being
in the JSP page.

Regards,

Simon


Reply via email to