/** * Removes the currently set bean and clears bound fields. If there is no * bound bean, does nothing. * <p> * This is a shorthand for {@link #setBean(Object)} with {@code null} bean. */ public void removeBean() { setBean(null); }
binder.setBean(bean); } else { binder.readBean(bean);
private void clearFields () { binder.setBean(new GLEntry()); }
/** * Sets the object to be edited by this form. This method binds all fields * from this form to given objects. * <p> * If your form needs to manually configure something based on the state of * the edited object, you can override this method to do that either before * the object is bound to fields or to do something after the bean binding. * * @param entity the object to be edited by this form */ public void setEntity(T entity) { this.entity = entity; this.settingBean = true; lazyInit(); if (entity != null) { binder.setBean(entity); hasChanges = false; setVisible(true); } else { binder.setBean(null); hasChanges = false; setVisible(false); } settingBean = false; }
/** * Provides EditorStuff for pojo - creates a new one or reuses one from pojoToEditor map. * Returned EditorStuff is never null. * * @param pojo the entity for which editor needs to be generated * @return editor stuff */ protected EditorStuff provideEditorStuff(ET pojo) { EditorStuff editorsstuff = pojoToEditor.get(pojo); if (editorsstuff == null) { Object o = createEditorInstance(pojo); Binder<ET> binder = instantiateBinder(elementType); binder.bindInstanceFields(o); binder.setBean(pojo); binder.addStatusChangeListener(scl); editorsstuff = new EditorStuff(binder, o); // TODO listen for all changes for proper modified/validity changes pojoToEditor.put(pojo, editorsstuff); } return editorsstuff; }
public NewEntryForm (GLTransaction transaction, TransactionsHelper helper, EntryGrid entryGrid) { super(); try { this.transaction = transaction.clone(); } catch (CloneNotSupportedException e) { // Log error and ignore. Clone should be supported. QI.getQI().getLog().error(e); } this.journal = transaction.getJournal(); this.helper = helper; this.app = QI.getQI(); this.entryGrid = entryGrid; setStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING); setSpacing(true); setWidthUndefined(); GLEntry entry = new GLEntry(); binder = new Binder (GLEntry.class); createAndBindFields(binder); binder.setBean(entry); binder.setReadOnly(true); addEntryBtn = new Button(app.getMessage("addEntry")); addEntryBtn.addClickListener(addEntryClickListener(binder)); addEntryBtn.setEnabled(false); addEntryBtn.setStyleName(ValoTheme.BUTTON_FRIENDLY); addComponent(addEntryBtn); setComponentAlignment(addEntryBtn, Alignment.BOTTOM_CENTER); }