How can I read out values from a form that contains dynamically created elements [message #1033718] |
Thu, 04 April 2013 15:04 |
Sebastiaan Hendriks Messages: 13 Registered: March 2013 Location: Netherlands |
Junior Member |
|
|
I'm creating a form (called GenericForm) which is going to allow the user to set parameters for the generation of reports. The form is going to contain an unknown amount of elements. These elements are being created on the form using a override of the InjectFieldsInternal function, showing here:
@Override
protected void injectFieldsInternal(List<IFormField> fieldList) {
List<ReportParameter> metadata = null;
if (reportId != null)
{
metadata = SERVICES.getService(IReportingService.class).getMetadataFromReport(reportId);
}
IFieldConstructorService constructService = SERVICES.getService(IFieldConstructorService.class);
Iterator<ReportParameter> metait = metadata.iterator();
while (metait.hasNext())
{
ReportParameter rp = metait.next();
if (rp.getName().equals("Unit"))
{
rp = metait.next();
}
String dataType = rp.getDataType();
switch (dataType)
{
case "date":
fieldList.add(constructService.AbstractDateField(rp.getName(), 0, true));
break;
case "string":
fieldList.add(constructService.AbstractStringField(rp.getName(), 0, true));
break;
default:
break;
}
}
fieldList.add(constructService.DefaultUnitBox());
fieldList.add(constructService.DefaultReportFormBox());
}
Normally when handeling the data from the form after the user is done with giving its preferred parameterdata, I would use the exportFormData function in the Handler to chuck it in a formData value, and then handle it from there.
public class ReportHandler extends AbstractFormHandler {
@Override
public void execLoad() throws ProcessingException {
}
@Override
public void execStore() throws ProcessingException {
GenericFormData formData = new GenericFormData();
exportFormData(formData); //formData remains to be empty
//Further handeling of formData
}
However, since I got dynamically created elements in GenericForm, they dont show up in my GenericFormData class which is used by the exportFormData function. Which in turn doesnt export the values from the form into the formData value. Atleast, if I understand it correctly.
Is there another way to get the data from the form, or am I tasked with somehow (temporarily) populating my GenericFormData class with the information required for scout to fill out the formData value via the exportFormData function?
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03166 seconds