2 Replies Latest reply on Jan 20, 2014 10:23 AM by Malte Pickhan

    Use ListWidget

    Malte Pickhan Newbie

      Hi there,

       

      i have problems by using the ListWidget...

       

      I have created a Widget, to map the entity, and refeer to it in the ListWidget. As soon as I add the first Element, the application only shows a blank page.


      Probably I am doing something wrong...

       

      ClassListWidget.java

      package de.coderebell.tts.client.local.widget; 
      
      import java.util.ArrayList; 
      import java.util.LinkedList; 
      import java.util.List; 
      
      import javax.annotation.PostConstruct; 
      import javax.inject.Inject; 
      
      import org.jboss.errai.ui.client.widget.ListWidget; 
      import org.jboss.errai.ui.shared.api.annotations.DataField; 
      import org.jboss.errai.ui.shared.api.annotations.Templated; 
      
      import com.google.gwt.user.client.ui.Composite; 
      
      import de.coderebell.tts.client.domain.SchoolClass; 
      
      @Templated(value = "ClassListWidget.html#body") 
      public class ClassListWidget extends Composite { 
      
          @Inject 
          @DataField 
          private ListWidget<SchoolClass, ClassWidget> classSelect; 
      
          @PostConstruct 
          public void init() { 
              // Somehow defunct 
              List<SchoolClass> result = new ArrayList(); 
              SchoolClass klasse = new SchoolClass(); 
              klasse.setClassName("Testklasse"); 
              klasse.setJahrgang(1987); 
              klasse.setKlassenId(1); 
              result.add(klasse); 
              classSelect.setItems(result); 
          } 
      }
      

       

      ClassListWidget.html

      <div id="wrap" data-field="body">
      <select data-field="classSelect"/>
      </div>
      

       

      ClassWidget.html

      <div id="wrap" data-field="body">
      <input data-field="klassenId" type="text"/>
      <input data-field="className" type="text"/>
      <input data-field="jahrgang" type="text"/>
      </div>
      

       

      ClassWidget.java

      package de.coderebell.tts.client.local.widget; 
      
      import javax.inject.Inject; 
      
      import org.jboss.errai.databinding.client.api.DataBinder; 
      import org.jboss.errai.ui.client.widget.HasModel; 
      import org.jboss.errai.ui.shared.api.annotations.AutoBound; 
      import org.jboss.errai.ui.shared.api.annotations.Bound; 
      import org.jboss.errai.ui.shared.api.annotations.DataField; 
      import org.jboss.errai.ui.shared.api.annotations.Templated; 
      
      import com.google.gwt.user.client.ui.Composite; 
      import com.google.gwt.user.client.ui.TextBox; 
      
      import de.coderebell.tts.client.domain.SchoolClass; 
      
      @Templated(value = "ClassWidget.html#body") 
      public class ClassWidget extends Composite implements HasModel<SchoolClass> { 
      
          @Inject 
          @AutoBound 
          private DataBinder<SchoolClass> classBinder; 
      
          @Inject 
          @Bound 
          @DataField 
          private TextBox klassenId; 
      
          @Inject 
          @Bound 
          @DataField 
          private TextBox className; 
      
          @Inject 
          @Bound 
          @DataField 
          private TextBox jahrgang; 
      
          @Override 
          public SchoolClass getModel() { 
              return classBinder.getModel(); 
          } 
      
          @Override 
          public void setModel(SchoolClass model) { 
              classBinder.setModel(model); 
          } 
      }
      

       

      Thanks in advance,

       

      Malte