formsgwtuibinder

How to design several forms with almost similar look?


I have about 6 forms to design with UIBinder that look almost the same, the difference is two or three fields. I was thinking about building one form with all the possible fields and hide or show fields depending on the case.

What do you think about this method?


Solution

  • It can work well. You can define a BaseForm class with UiBinder that implements HasWidgets, and then define SpecificForm1.ui.xml with something like

    <custom:BaseForm>
        <g:TextBox ui:field="componentSpecificToThisForm" />
        <g:Button>A button!</g:button>
    </custom:BaseForm>
    

    and SpecificForm2.ui.xml with something like

    <custom:BaseForm>
        <g:Label>Something totally different</g:Label>
        <g:Button>A button!</g:button>
    </custom:BaseForm>
    

    it works great!