2 Replies Latest reply on May 8, 2014 10:02 PM by gmoga

    Errai UI - Widgets not referenced in the template html

    gmoga

      Hi all,

       

      I have been doing some proof of concept with Errai UI  and so far it seems very powerful but I have some questions about templating (Mapping template html fields with its Class DataFields).

      Based on the Errai tutorial we have part of the Admin.html that looks like:

      <table class="table striped blackened">

                <tbody id="complaints">

                  <tr id="complaint" valign="top" class="issue-open">

                    <td data-field="name">Lincoln Baxter, III</td>

                    <td data-field="email">lincolnbaxter@gmail.com</td>

                     ...

                  </tr>

      </table>

       

      And the template class related to each row is ComplaintListItemWidget that looks like

      @Templated("Admin.html#complaint")

      public class ComplaintListItemWidget extends Composite implements HasModel<UserComplaint> {

        @Inject

        @AutoBound

        private DataBinder<UserComplaint> userComplaint;

      ...

          @Bound

        @DataField

        private final Element name = DOM.createTD();

       

        @Bound

        @DataField

        private final Element email = DOM.createTD();

      ...

       

      My question is: if I need to remove the email TD of the template html, then it also must be removed from the ComplaintListItemWidget class?. Is there a more flexible way to go (like mark the @Datafield not mandatory for example) in the template to put or remove things.

       

      Thanks in advance for your answer

        • 1. Re: Errai UI - Widgets not referenced in the template html
          csa

          Hi Gerardo,

           

          There's currently no way to mark a @DataField as optional. This wouldn't be hard to implement though. Can you describe your use case for this?

           

          Cheers,

          Christian

          1 of 1 people found this helpful
          • 2. Re: Errai UI - Widgets not referenced in the template html
            gmoga

            Hi Christian,

             

            Thanks for the information.

             

            So far I would like to be able to do some templating changes in a flexible way, as I do not want to change my class (template) if I remove a column in the template.

            The approach you mention sounds good, and definetly will solve some part of the situation. I will be aware of any change or improvement related.

             

            Thanks in advance,

            Gerardo