Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jboss.errai.demo.grocery.client.local;
 
 
@Templated("#main")
public class ItemWidget extends Composite {
  @Inject private @Bound @DataField Label name;
  @Inject private @Bound @DataField Label comment;
  private @Bound(converter=RelativeTimeConverter.class) @DataField Element addedOn = DOM.createSpan();
  private @Bound(converter=UsernameConverter.class) @DataField Element addedBy = DOM.createSpan();
  @Inject private @DataField Label department;
  void init() {
    .bind("name");
    // need to switch the databinder's model when the item's department reference changes
      @Override
      public void onPropertyChange(PropertyChangeEvent<Departmentevent) {
        .setModel(event.getNewValue());
      }
    });
    // TODO (ERRAI-382) convert these to a method with @EventHandler("this")
      @Override
      public void onMouseOver(MouseOverEvent event) {
        ..println("MouseOver " + .getModel().getName());
        addStyleName("active");
      };
    }, MouseOverEvent.getType());
      @Override
      public void onMouseOut(MouseOutEvent event) {
        ..println("MouseOut " + .getModel().getName());
        removeStyleName("active");
      };
    }, MouseOutEvent.getType());
  }

  
Changes the model object visualized by this class to the given one.

Parameters:
item The item that should become the model of this class. Must not be null.
Returns:
The proxied version of the given item object, for purposes of data binding. If you intend to make any changes to the state of the item after adding it to this widget, you must do so via this returned proxy. If you modify the item directly (rather than via the proxy) then this UI widget will not update.
  public Item setItem(Item item) {
    ..println("ItemWidget: adopting model object " + System.identityHashCode(item));
    if (item.getDepartment() == null) {
      item.setDepartment(new Department());
    }
    return .setModel(item.);
  }
New to GrepCode? Check out our FAQ X