Display a list of objects.

Skip to first unread message

Guillen Antonio

Nov 1, 2021, 1:41:25 PM11/1/21
to GWT Users
I've been struggling for days to display a list of objects in an editor using UIBinder.

But I can't figure out which class to use and even less how.

Here are some code snippets:

The UIBinder file
<!-- EventImplEditor.ui.xml file -->
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
        .widget {
           margin: 30px;
   <m:MaterialDialog ui:field="dialog" width="300px)">
      <m:MaterialContainer ui:field="container" width="300px)" addStyleNames="{style.widget}">
                <m:MaterialButton  ui:field="exit" text="Exit"/>
    <m:MaterialTextBox ui:field="name" label="Name" iconType="FACE" />
    <m:MaterialTextBox ui:field="graphID" label="GraphID" iconType="FACE" />
    <m:MaterialPanel ui:field="MaterialPanelCombo2">
    <m:MaterialPanel ui:field="MaterialPanelCombo3">
    <m:MaterialPanel ui:field="MaterialPanelCombo4">
    <m:MaterialPanel ui:field="MaterialPanelCombo5">
    <m:MaterialPanel ui:field="MaterialPanelCombo6">
    <!-- Here I tried to put List box  but no result -->
    <g:ListBox ui:field="canBeusedBy" />

The Editor Java file

package com.lacen.gwt.spot.client.ui.mvp.editors.generated;
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.editor.client.Editor;
 import com.google.gwt.editor.client.SimpleBeanEditorDriver;
 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.uibinder.client.UiBinder;
 import com.google.gwt.uibinder.client.UiField;
 import com.google.gwt.uibinder.client.UiHandler;
 import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.Widget;
 import com.lacen.event.Event;
 import gwt.material.design.client.ui.MaterialPanel;
 import com.lacen.gwt.spot.client.ui.mvp.editors.ComboBoxEnum;
 import gwt.material.design.client.ui.MaterialDialog;
 import gwt.material.design.client.ui.MaterialTextBox;
 import com.google.gwt.user.client.ui.ListBox;
 import java.util.List;
 import com.lacen.gwt.spot.client.ui.mvp.editors.ListValueSpot;
 import com.lacen.users.Stakeholder;
 import com.lacen.organisation.Action;
 * Create an editor to describe a event.
 * @author Antonio
 public class EventEditor extends Composite implements Editor<Event> {
      /** The Constant driver. */
      // Editor driver
      private static final EventDriver driver = GWT.create(EventDriver.class);
      * The Interface EventDriver.
      interface EventDriver extends SimpleBeanEditorDriver<Event, EventEditor> {
      /** The Constant uiBinder. */
      // UiBinder and fields
      private static final EventEditorUiBinder uiBinder = GWT.create(EventEditorUiBinder.class);
      * The Interface EventEditorUiBinder.
      interface EventEditorUiBinder extends UiBinder<Widget, EventEditor> {
      /** The dialog. */
      MaterialDialog dialog;
      /** The name */
      MaterialTextBox name;
      /** The graphID */
      MaterialTextBox graphID;
      /** The eventStatus */
      MaterialPanel MaterialPanelCombo2;
      ComboBoxEnum<com.lacen.event.HandlingProgress> eventStatus;
      /** The relevance */
      MaterialPanel MaterialPanelCombo3;
      ComboBoxEnum<com.lacen.event.Relevance> relevance;
      /** The status */
      MaterialPanel MaterialPanelCombo4;
      ComboBoxEnum<com.lacen.event.StatusEvent> status;
      /** The detectability */
      MaterialPanel MaterialPanelCombo5;
      ComboBoxEnum<com.lacen.event.Detectability> detectability;
      /** The criticity */
      MaterialPanel MaterialPanelCombo6;
      ComboBoxEnum<com.lacen.event.Criticality> criticity;
      /** The canBeusedBy */
      ListBox canBeusedBy;
      /** The initial object (Event). */
      private Event initialObject;
      * Instantiates a new Event editor.
      public EventEditor() {
           initWidget(uiBinder.createAndBindUi(this)); //// Create the UI of the Editor.
           eventStatus = new ComboBoxEnum<com.lacen.event.HandlingProgress>("eventStatus", com.lacen.event.HandlingProgress.VALUES);
           relevance = new ComboBoxEnum<com.lacen.event.Relevance>("relevance", com.lacen.event.Relevance.VALUES);
           status = new ComboBoxEnum<com.lacen.event.StatusEvent>("status", com.lacen.event.StatusEvent.VALUES);
           detectability = new ComboBoxEnum<com.lacen.event.Detectability>("detectability", com.lacen.event.Detectability.VALUES);
           criticity = new ComboBoxEnum<com.lacen.event.Criticality>("criticity", com.lacen.event.Criticality.VALUES);
           dialog.open(); //// Visualize the editor.
      * Initialize and fill in the editors fields with the Event properties.
      * @param obj the Event.
      public void edit(Event obj) {
           this.initialObject = obj;
           driver.initialize(this); //// Initialize the driver
           driver.edit(this.initialObject); //// Fill the editor with the object
      * Exit the editor closing the dialog.
      * @param event the event
      public void onExitSelect(ClickEvent event) {

In my Event object model, "canBeusedBy" is the name of a "Stakeholder" list that I want to display in the ListBox.

When I call my editor everything is displayed but not the list?  Here after a copy of the editor displayed:

Do you have an idea, a specific example with a list of objects.

Thank you for your help.


Craig Mitchell

Nov 3, 2021, 5:50:16 PM11/3/21
to GWT Users
I'm not familiar with the material UI.  However, I can see you're missing the "@UiField" on your ListBox declaration.  ie: It should be:
@UiField ListBox canBeusedBy;

Then you call just call "addItem" to add some items into the list.  See http://samples.gwtproject.org/samples/Showcase/Showcase.html#!CwListBox for more detail.

Guillen Antonio

Nov 4, 2021, 3:51:20 AM11/4/21
to google-we...@googlegroups.com
Hi Graig,
Thanks for your proposal. But even adding the tag @UiFieldI nothing is displayed.


You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/88ef9293-7280-45d8-9690-439a7131817an%40googlegroups.com.
Reply all
Reply to author
0 new messages