@Override
 protected void updateForm(PersonFormForMultiStep form) {
   if (form.getId() == null) {
     PersonDbManager.instance().add(Person.createByForm(form));
     // output the success message to specified DOM rather than the global message bar
     DefaultMessageRenderingHelper.getConfiguredInstance().info(".x-success-msg", "data inserted");
   } else {
     Person p = Person.createByForm(form);
     PersonDbManager.instance().update(p);
     // output the success message to specified DOM rather than the global message bar
     DefaultMessageRenderingHelper.getConfiguredInstance()
         .info(".x-success-msg", "update succeed");
   }
 }
Beispiel #2
0
 public Renderer render() {
   List<Person> personList = PersonDbManager.instance().findAll();
   return Renderer.create(
       ".x-row",
       personList,
       new RowRenderer<Person>() {
         @Override
         public Renderer convert(int rowIndex, Person row) {
           Renderer renderer = Renderer.create();
           renderer.add(".x-check input", "value", row.getId());
           renderer.add(".x-name", row.getName());
           renderer.add(".x-age", row.getAge());
           if (row instanceof SubPersonForm) {
             renderer.add(".x-sex", "-");
             renderer.add(".x-blood", "-");
             renderer.add(".x-language", "-");
           } else {
             renderer.add(".x-sex", row.getSex());
             renderer.add(".x-blood", row.getBloodType());
             renderer.add(".x-language span", Arrays.asList(row.getLanguage()));
           }
           return renderer;
         }
       });
 }
 @Override
 protected PersonFormForMultiStep createInitForm() throws Exception {
   PersonFormForMultiStep form = super.createInitForm();
   if (form.getId() == null) { // add
     return form;
   } else { // update
     // retrieve the form form db again
     return PersonFormForMultiStep.buildFromPerson(PersonDbManager.instance().find(form.getId()));
   }
 }