예제 #1
0
 protected void exportForm(FormRepresentation form) {
   FormRepresentationEncoder encoder = FormEncodingFactory.getEncoder();
   try {
     String formAsJson = encoder.encode(form);
     setClientExportForm(formAsJson);
   } catch (FormEncodingException e) {
     bus.fireEvent(new NotificationEvent(Level.ERROR, i18n.CouldntExportAsJson(), e));
   }
 }
 @Override
 @SuppressWarnings("unchecked")
 public void setDataMap(Map<String, Object> data) throws FormEncodingException {
   super.setDataMap(data);
   this.cssClassName = (String) data.get("cssClassName");
   this.id = (String) data.get("id");
   this.legend = (String) data.get("legend");
   Map<String, String> i18nMap = (Map<String, String>) data.get("i18n");
   if (i18nMap != null) {
     this.i18n = new HashMap<String, String>();
     this.i18n.putAll(i18nMap);
   }
   this.items.clear();
   List<Object> mapItems = (List<Object>) data.get("items");
   FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder();
   if (mapItems != null) {
     for (Object obj : mapItems) {
       Map<String, Object> itemMap = (Map<String, Object>) obj;
       FormItemRepresentation item = (FormItemRepresentation) decoder.decode(itemMap);
       this.items.add(item);
     }
   }
 }