use of com.servoy.j2db.server.ngclient.property.ComponentTypeFormElementValue in project servoy-client by Servoy.
the class FormComponentSabloValue method getComponents.
private ComponentTypeSabloValue[] getComponents() {
FormComponentCache formComponentCache = getCache();
if (currentFormComponentCache != formComponentCache) {
List<FormElement> elements = formComponentCache.getFormComponentElements();
List<ComponentTypeSabloValue> componentsList = new ArrayList<ComponentTypeSabloValue>(elements.size());
PropertyPath path = new PropertyPath();
path.add(component.getName());
path.add("containedForm");
path.add("childElements");
JSONObject tags = new JSONObject();
tags.put(ComponentTypeSabloValue.TAG_ADD_TO_ELEMENTS_SCOPE, true);
PropertyDescription compPd = new PropertyDescriptionBuilder().withName(pd.getName()).withType(ComponentPropertyType.INSTANCE).withConfig(pd.getConfig()).withTags(tags).build();
int j = 0;
for (FormElement element : elements) {
path.add(j);
ComponentTypeFormElementValue elementValue = ComponentPropertyType.INSTANCE.getFormElementValue(null, compPd, path, element, dal.getApplication().getFlattenedSolution());
ComponentTypeSabloValue ctsv = ComponentPropertyType.INSTANCE.toSabloComponentValue(elementValue, compPd, element, component, dal);
if (ctsv != null) {
// if it is null then it is probably a child component that was blocked by security (visibility == false); in that case just ignore it (similar to what portal does through .spec setting on comp. array to ignore null values at runtime)
j++;
componentsList.add(ctsv);
}
path.backOneLevel();
if (element.getWebComponentSpec() != null) {
Collection<PropertyDescription> properties = element.getWebComponentSpec().getProperties(FormComponentPropertyType.INSTANCE);
if (properties.size() > 0) {
for (PropertyDescription pd : properties) {
Object propertyValue = element.getPropertyValue(pd.getName());
Form frm = FormComponentPropertyType.INSTANCE.getForm(propertyValue, dal.getApplication().getFlattenedSolution());
if (frm == null)
continue;
FormComponentCache innerCache = FormElementHelper.INSTANCE.getFormComponentCache(element, pd, (JSONObject) propertyValue, frm, dal.getApplication().getFlattenedSolution());
List<FormElement> innerElements = innerCache.getFormComponentElements();
for (FormElement innerElement : innerElements) {
path.add(j);
elementValue = ComponentPropertyType.INSTANCE.getFormElementValue(null, compPd, path, innerElement, dal.getApplication().getFlattenedSolution());
// use main property
ctsv = ComponentPropertyType.INSTANCE.toSabloComponentValue(elementValue, compPd, innerElement, component, dal);
if (ctsv != null) {
// if it is null then it is probably a child component that was blocked by security (visibility == false); in that case just ignore it (similar to what portal does through .spec setting on comp. array to ignore null values at runtime)
j++;
componentsList.add(ctsv);
}
path.backOneLevel();
}
}
}
}
}
// re-attach
if (currentFormComponentCache != null && changeMonitor != null && webObjectContext != null) {
for (ComponentTypeSabloValue componentTypeSabloValue : componentsList) {
componentTypeSabloValue.attachToBaseObject(changeMonitor, webObjectContext);
}
}
currentFormComponentCache = formComponentCache;
components = componentsList.toArray(new ComponentTypeSabloValue[0]);
}
return components;
}
Aggregations