use of org.santfeliu.form.Form in project gdmatrix by gdmatrix.
the class HtmlFormRenderer method decode.
@Override
public void decode(FacesContext context, UIComponent component) {
DynamicForm dynamicForm = (DynamicForm) component;
Form form = dynamicForm.getForm();
if (form == null)
return;
Map<String, String[]> submittedData = new HashMap<>();
dynamicForm.setSubmittedValue(submittedData);
Map parameters = context.getExternalContext().getRequestParameterValuesMap();
String clientId = component.getClientId(context);
for (Field field : form.getFields()) {
String name = field.getReference();
String[] stringValues = (String[]) parameters.get(getFieldId(clientId, name));
View view = form.getView(name);
if (view != null && View.BUTTON.equals(view.getViewType())) {
submittedData.put(name, stringValues);
if (stringValues != null) {
// button pressed
ActionEvent event = new ActionEvent(component);
event.setPhaseId(PhaseId.INVOKE_APPLICATION);
component.queueEvent(event);
}
} else if (stringValues != null) {
submittedData.put(name, stringValues);
}
// else if (Field.BOOLEAN.equals(field.getType()))
// {
// // special case: checkboxes don't send fieldValue when not checked.
// // put 'false' fieldValue in this case
// if (stringValues == null) submittedData.put(name, new String[]{"false"});
// }
}
// All submitted values are String[], conversion takes place in next phase
System.out.println("\nSUBMITTED DATA================================== ");
printMap(submittedData);
}
use of org.santfeliu.form.Form in project gdmatrix by gdmatrix.
the class URLFormBuilder method getForm.
public Form getForm(String selector) {
Form form = null;
URL url = getURL(selector);
if (url != null) {
Class formClass = getFormClass(url.getFile());
if (formClass == null) {
try {
URLConnection conn = url.openConnection();
String contentType = conn.getContentType();
if (contentType.indexOf("html") != -1) {
formClass = HtmlForm.class;
}
} catch (Exception ex) {
}
}
if (formClass != null) {
try {
form = (Form) formClass.newInstance();
form.read(url.openStream());
setup(form);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
}
return form;
}
use of org.santfeliu.form.Form in project gdmatrix by gdmatrix.
the class FormTestBean method getFormEntryClass.
public String getFormEntryClass() {
FormFactory.Entry entry = (FormFactory.Entry) getValue("#{row}");
Form form = entry.getForm();
return form.getClass().getName();
}
use of org.santfeliu.form.Form in project gdmatrix by gdmatrix.
the class FormTestBean method getFormFields.
public List getFormFields() {
Form form = getForm();
if (form == null)
return Collections.EMPTY_LIST;
List list = new ArrayList();
list.addAll(form.getFields());
return list;
}
use of org.santfeliu.form.Form in project gdmatrix by gdmatrix.
the class PathFormBuilder method getForm.
public Form getForm(String selector) {
Form form = null;
File file = getFile(selector);
if (file != null && file.isFile()) {
Class formClass = getFormClass(file.getName());
if (formClass != null) {
try {
form = (Form) formClass.newInstance();
form.read(new FileInputStream(file));
setup(form);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
}
return form;
}
Aggregations