CellList - is there a better way than building raw html?

79 views
Skip to first unread message

markww

unread,
Sep 5, 2012, 11:46:03 AM9/5/12
to google-we...@googlegroups.com
Hi,

I'm looking at the CellList demo, the AbstractCell implementation is generating raw html strings for a cell presentation implementation:



  static class ContactCell extends AbstractCell<ContactInfo> {

      ... 

      @Override
      public void render(Context context, ContactInfo value, SafeHtmlBuilder sb) {
          sb.appendHtmlConstant("<table>");

          // Add the name and address.
          sb.appendHtmlConstant("<td style='font-size:95%;'>");
          sb.appendEscaped(value.getFullName());
          sb.appendHtmlConstant("</td></tr><tr><td>");
          sb.appendEscaped(value.getAddress());
          sb.appendHtmlConstant("</td></tr></table>");
      }
  }

is this the recommended way to go? Is there no way to use any of the panel classes to implement the cell presentation? I was thinking we could provide something like a VerticalPanel etc to stay within GWT land.

Thanks



Jens

unread,
Sep 5, 2012, 12:00:29 PM9/5/12
to google-we...@googlegroups.com
In GWT 2.5 you can use UiBinder for Cells so you don't have to write the raw HTML inside your code.


But you can't use ordinary GWT widgets like Buttons, etc inside Cells.

-- J.

markww

unread,
Sep 5, 2012, 12:08:58 PM9/5/12
to google-we...@googlegroups.com
Hi Jens,

Let's say I only plan on having 20 rows at any given time. If I were to implement a list using a ScrollPanel + 20 VerticalPanel instances as rows, could you see that working? I'd be mostly concerned with being able to scroll the list nicely on mobile devices (fling scrolling, elastic bounce back like CellList has). Also not clear how click handling a VerticalPanel as a row would work. Ideally would want the entire VerticalPanel to have an onClick state to give the user visual feedback that they've clicked it. Possible?

Thank you

BM

unread,
Jan 29, 2013, 11:18:03 AM1/29/13
to google-we...@googlegroups.com
Not sure if you got this working. But one can't use Vertical Panel as cell rows inside any Cell Widgets. GWT widgets (Vertical Panels, Horizontal Panel, GWT Button, GWT textbox, etc) can't be used inside Cell because they are heavyweight components and very slow so if used would defeat the purpose of lightweight faster Cell Widgets. GWT Cell Widget package provide 16 different types of Cell types and one can make custom cells using these cell types with UIRenderer. 

Make a custom Cell type and use that in CellList. Add SelectionHandlerModel or OnBrowserEvent inside CellType.
Reply all
Reply to author
Forward
0 new messages