2011-04-07

Define GXT Templates in UiBinder

For my gxt-uibinder demo, I've been going through the Ext GWT Explorer and carefully converting what Sencha has done programmatically into XML UiBinder representation. There have been many hurdles to jump, but overall, things have been going well.

Recently, I've been in the mood to experiment with UiBinder, specifically with the <ui:...> type elements.  That is the portion of UiBinder I haven't really tapped into (with my other open source project gwt-customuibinder).

My next experiment is going to be to include custom Resource parsers.  This way, you're not limited to just the <ui:data>, <ui:image>, <ui:import>, <ui:style>, and <ui:with>.  I would like to have reusable GXT Templates and XTemplates.  This may look something similar to the following:

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
 xmlns:gxtui='urn:ui:com.jhickman.web.gwt.gxtuibinder'
        ....>

  <gxtui:xtemplate name="stateTemplate">
    <tpl for="."> 
       <div class="x-combo-list-item"
               qtip="{slogan}" qtitle="State Slogan">{name}</div> 
    </tpl> 
  </gxtui:xtemplate>

  ...
  <form:ComboBox
    emptyText="Select a state..."
    displayField="name"
    template="{stateTemplate}"
    width="150"
    store="{stateStore}"
    typeAhead="true"
    triggerAction="ALL" />
    
  ...

</ui:UiBinder>

With the current state of the GWT UiBinder code, it makes it very difficult to extend as most methods and fields are private.  To get my custom ElementParsers working in gwt-customuibinder, I had to use a lot of reflection.

Who knows.  It may give me such a headache, I'll end up reverting my changes and moving on.