incubator-adffaces-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bertrand, Shawn R" <shawn.bertr...@tycoelectronics.com>
Subject RE: Layout components in custom renderers
Date Thu, 22 Feb 2007 15:17:01 GMT
Thanks, Adam.

Can you speak to the part about assembling them in a component
hierarchy?  I realize the ease of using *Element calls on the
ResponseWriter, but I'd like to see how it would be done if real Html*
components were used.

All the best,

Shawn


-----Original Message-----
From: Adam Winer [mailto:awiner@gmail.com] 
Sent: Thursday, February 22, 2007 1:07 AM
To: adffaces-user@incubator.apache.org
Subject: Re: Layout components in custom renderers

To use table layout, etc., you assemble all
of them into one component hierarchy, and
then call encodeAll() on the root.  These are
components where rendersChildren="true", so you can't
just render them with encodeBegin()/encodeEnd().

But these components (all the ones we
call "Html" instead of "Core") really don't abstract
you very much from the underlying HTML.
So, honestly, you might do just as well to write

ResponseWriter rw = context.getResponseWriter();
rw.startElement("table", null);
rw.startElement("tr", null);

... etc...

-- Adam



On 2/21/07, Bertrand, Shawn R <shawn.bertrand@tycoelectronics.com>
wrote:
> Hi all,
>
>
>
> I'd like to use the Trinidad layout components (HtmlTableLayout,
> HtmlRowLayout, and HtmlCellFormat) in a custom component I've
developed,
> but I'm not sure how to integrate each component of the table
together.
> I'm sure I'm missing something basic (like linking them in
parent-child
> relationships), so thanks for your help in clarifying this.
>
>
>
> I originally thought calling the encode methods would do the trick,
but
> output suggested that rows need to be linked to the table, and cells
> need to be linked to the rows.  The code I had is below.
>
>
>
> Thanks,
>
>
>
> Shawn
>
>
>
>
>
>         // Start JSF table layout
>
>         HtmlTableLayout tblLayout = new HtmlTableLayout();
>
>         tblLayout.setBorderWidth(0);
>
>         tblLayout.setCellPadding(3);
>
>         tblLayout.setCellSpacing(3);
>
>         tblLayout.encodeBegin(context);
>
>
>
>         // Iterate over each row
>
>         HtmlRowLayout rowLayout;
>
>         HtmlCellFormat cellFormat;
>
>         for (LabelFieldComponent comp : comps)
>
>         {
>
>             // Start row
>
>             rowLayout = new HtmlRowLayout();
>
>             rowLayout.encodeBegin(context);
>
>
>
>             // Start label cell
>
>             cellFormat = new HtmlCellFormat();
>
>             cellFormat.setHalign(comp.getLabel().getHAlign());
>
>
>
cellFormat.setHeight(Integer.valueOf(comp.getLabel().getHeight()).toStri
> ng());
>
>
>
cellFormat.setWidth(Integer.valueOf(comp.getLabel().getWidth()).toString
> ());
>
>             cellFormat.setValign(comp.getLabel().getVAlign());
>
>             cellFormat.encodeBegin(context);
>
>
>
>             // Insert label
>
>             writer.write(comp.getLabel().getText());
>
>
>
>             // End label cell
>
>             cellFormat.encodeEnd(context);
>
>
>
>             // Start field cell
>
>             cellFormat = new HtmlCellFormat();
>
>             cellFormat.setHalign(comp.getField().getHAlign());
>
>
>
cellFormat.setHeight(Integer.valueOf(comp.getField().getHeight()).toStri
> ng());
>
>             cellFormat.setValign(comp.getField().getVAlign());
>
>             cellFormat.encodeBegin(context);
>
>
>
>             // Insert field
>
>             writer.write(comp.getField().getHTML());
>
>
>
>             // End label cell
>
>             cellFormat.encodeEnd(context);
>
>
>
>             // End row
>
>             rowLayout = new HtmlRowLayout();
>
>             rowLayout.encodeEnd(context);
>
>         }
>
>
>
>         // Complete layout
>
>         tblLayout.encodeEnd(context);
>
>
>
>

Mime
View raw message