dev@jsftemplating.java.net

Re: JSFTemplating: Enhancement #10: Dynamic table

From: Ken Paulsen <Ken.Paulsen_at_Sun.COM>
Date: Tue, 04 Sep 2007 14:10:54 -0700

Hi Karam,

This explains what you're trying to do very well.

The best approach that comes to mind is to use an "afterCreate" event on
the DynamicColumnTableRowGroup.

This would allow you to create a new column (the "Total Usage" coumn),
and move all the appropriate columns under it.

<!afterCreate
    createAndMoveColumns(tableRowGroup="$this{component}");
/>

    @Handler(id="createAndMoveColumns",
        input={
            @HandlerInput(name="tableRowGroup", type=UIComponent.class,
required=true)})
    public static void createAndMoveColumns(HandlerContext context) {
        UIComponent trg = (UIComponent)
context.getInputValue("tableRowGroup");
        TableColumn totalColumn = new TableColumn(...);
        totalColumn.set...(...);
        List<UIComponent> children = trg.getChildren();
        children.add(totalColumn);
        List<UIComponent> totalChildren = totalColumn.getChildren();
        for (UIComponent child : children) {
          if (child....) {
              totalChildren.add(child);
          }
        }
    }
       
The above code isn't complete, but I think you get the idea. You could
pass in more data if you need (i.e. the heading, or other info you need
to figure out which columns to move). Adding a UIComponent to another
UIComponent removes it from where it previously was, so no need to
remove anything.

I hope this helps!

Ken


Karam.Badesha_at_Sun.COM wrote:
> Ken,
> Attached are those table images. If you look at the old table, you
> will see that there is "Total Usage" as heading for all the projects
> (IG, ROCK, N2 ...). This is done by putting tableColumn within a
> tableColumn.
>
> <sun: tableColumn
> id=col2
> headerText=xxx
> >
>
> <sun: tableColumn
> id=subcol1
> headerText=xxx
> />
>
> <sun: tableColumn
> id=subcol2
> headerText=xxx
> />
> </sun: tableColumn>
>
> I need a way to do this using dynamic table. Does this help or shouldI
> send the real code?
>
> thanks
> Karam
>
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>