public class GridFormEncoderDemo extends GridFormDemo { @InjectComponent private Grid grid; void setupRender() { if (grid.getSortModel().getSortConstraints().isEmpty()) grid.getSortModel().updateSort("title"); } }
private String getComponentId(PlasticField field, InjectComponent annotation) { String id = annotation.value(); if (InternalUtils.isNonBlank(id)) return id; return InternalUtils.stripMemberName(field.getName()); } }
public class InjectComponentDemo { @InjectComponent private Form form; @InjectComponent("form") private Form form2; public String getInjectComponentId() { return Form.class.getName() + "[" + form.getClientId() + "--" + form2.getClientId() + "]"; } }
public class MissingEmbeddedComponent { @InjectComponent private TextField missing; }
public class InjectComponentMismatch { @InjectComponent private Form form; }
public class TreeDemo { @InjectComponent private Tree tree; public TreeModel<Stuff> getStuffModel() { return Stuff.createTreeModel(); } void onActionFromClear() { tree.clearExpansions(); } }
public class FormZoneDemo { @Property private Long longValue; @InjectComponent private Zone valueZone; Object onSuccess() { return valueZone.getBody(); } }
public class HasBodyDemo { @InjectComponent @Property private Component nobody; @InjectComponent @Property private Component somebody; }
public class GridEarlyPagingDemo { @Inject private MusicLibrary library; @InjectComponent private Grid grid; public List<Track> getTracks() { return library.getTracks(); } @SetupRender void jumpTo2ndPage(){ grid.setCurrentPage(2); } }
public class ZoneUpdateNamespace { @InjectComponent private Zone zone; @Property private String message; Object onSuccess() { message = "Zone updated"; return zone.getBody(); } public Date getNow() { return new Date(); } }
public class ZoneRefreshWithHandlerReturningZone { @Persist @Property private int counter; @InjectComponent private Zone zone; @InjectComponent private Zone zone2; void setupRender() { counter = 0; } Object onRefreshFromZone(){ counter++; return new MultiZoneUpdate(zone).add(zone2); } }
@InjectComponent @Property private Submit submit;
public class GridDemo { @Inject private MusicLibrary library; @Property private Track track; @InjectComponent private Grid grid; public List<Track> getTracks() { return library.getTracks(); } void onActionFromReset() { grid.reset(); } void onActionFromSortRating() { grid.getSortModel().updateSort("rating"); } }
public class FormFieldClientIdParameterDemo { public final static int ITERATIONS = 2; @Property private String string; @Property private int index; @InjectComponent private Zone zone; public int[] getSource() { return new int[ITERATIONS]; // values itself don't matter, just length of array } public String getClientId() { return "clientId-" + index; } Object onUpdateZone() { return zone.getBody(); } }
public class Ajaxified extends UploadBasePage { @Inject private Block content; @InjectComponent private ClientElement injector; @Environmental private JavaScriptSupport javaScriptSupport; Object onActionFromInjector() { return content; } void afterRender() { javaScriptSupport.addScript( "$('trigger').observe('click', function(event) { $('%s').trigger(); Event.stop(event); });", injector.getClientId()); } }
public class FormFieldFocusDemo { @InjectComponent @Property private Field gainFocus; @Property private String requiredValue; @Property private String gainFocusValue; void beginRender() { requiredValue = "I'm required"; gainFocusValue = "But I got the focus!"; } }
private TreeSelectionModel selectionModel; @InjectComponent private Tree tree;
private Track track; @InjectComponent private Grid grid;
@Import(stack = "core") public class InjectValidatorDemo { @NotNull(groups=Bar.class) @Validate("minlength=5") @Property @Persist private String userName; @Inject private Validator validator; @InjectComponent private Form form; void onValidateFromForm() { Set<ConstraintViolation<InjectValidatorDemo>> violations = validator.validate(this, Bar.class); for (ConstraintViolation<InjectValidatorDemo> next : violations) { form.recordError("User Name "+next.getMessage()); } } }
private String context2; @InjectComponent private Grid music;