use of com.servoy.j2db.server.ngclient.WebFormComponent in project servoy-client by Servoy.
the class ValueListTypeSabloValue method getTableForDp.
/**
* If this valuelist is for a dataprovider and that dataprovider is for a foundset (or even from form's foundset) then this method gives the correct table to search in for that DP.
* The DP might not be from this table though, it could still be a global variable or form variable.
*
* @return the table to search DP in
*/
private ITable getTableForDp() {
ITable table;
if (foundsetPropertySabloValue != null)
table = foundsetPropertyTable;
else {
IWebFormUI formUI = ((WebFormComponent) webObjectContext.getUnderlyingWebObject()).findParent(WebFormUI.class);
table = formUI.getController().getTable();
}
return table;
}
use of com.servoy.j2db.server.ngclient.WebFormComponent in project servoy-client by Servoy.
the class FormTemplateObjectWrapper method wrap.
@Override
public TemplateModel wrap(Object obj) throws TemplateModelException {
TemplateModel model = wrapperCache.get(obj);
if (model != null)
return model;
Object wrapped;
if (obj instanceof Form) {
wrapped = getFormWrapper((Form) obj);
} else if (obj instanceof Object[]) {
this.flattenedForm = context.getSolution().getFlattenedForm((Form) ((Object[]) obj)[0]);
wrapped = new FormWrapper(flattenedForm, (String) ((Object[]) obj)[1], useControllerProvider, context, design, runtimeProperties != null ? runtimeProperties.getJSONObject("") : null);
} else if (obj == DefaultNavigator.INSTANCE) {
wrapped = new FormElement(DefaultNavigator.INSTANCE, context.getSolution(), new PropertyPath(), design);
JSONObject object = runtimeProperties != null ? runtimeProperties.optJSONObject(((FormElement) wrapped).getName()) : null;
if (object != null) {
wrapped = new FormElementContext((FormElement) wrapped, context, object);
}
} else if (obj instanceof Part) {
wrapped = new PartWrapper((Part) obj, flattenedForm, context, design);
} else if (obj instanceof IFormElement) {
FormElement fe = null;
if (formUI != null) {
List<FormElement> cachedFormElements = formUI.getFormElements();
for (FormElement cachedFE : cachedFormElements) {
if (Utils.equalObjects(cachedFE.getPersistIfAvailable(), obj)) {
fe = cachedFE;
break;
}
}
if (fe == null) {
Form parentForm = (Form) ((IFormElement) obj).getAncestor(IRepository.FORMS);
if (parentForm != null && parentForm.isFormComponent()) {
for (WebComponent webComponent : formUI.getAllComponents()) {
if (webComponent instanceof WebFormComponent) {
FormElement cachedFE = ((WebFormComponent) webComponent).getFormElement();
if (Utils.equalObjects(cachedFE.getPersistIfAvailable(), obj)) {
fe = cachedFE;
break;
}
}
}
}
}
}
FormElement formElement = fe != null ? fe : FormElementHelper.INSTANCE.getFormElement((IFormElement) obj, context.getSolution(), null, false);
JSONObject object = runtimeProperties != null ? runtimeProperties.optJSONObject(formElement.getName()) : null;
wrapped = new FormElementContext(formElement, context, object);
} else {
wrapped = obj;
}
TemplateModel wrap = super.wrap(wrapped);
wrapperCache.put(obj, wrap);
return wrap;
}
use of com.servoy.j2db.server.ngclient.WebFormComponent in project servoy-client by Servoy.
the class CSSPositionPropertyType method toJSON.
public JSONWriter toJSON(JSONWriter writer, String key, CSSPosition object, PropertyDescription pd, DataConversion clientConversion, IBrowserConverterContext dataConverterContext) throws JSONException {
FormElement fe = null;
if (dataConverterContext != null && dataConverterContext.getWebObject() instanceof WebFormComponent) {
fe = ((WebFormComponent) dataConverterContext.getWebObject()).getFormElement();
}
FlattenedSolution fs = null;
Form form = null;
if (dataConverterContext != null && dataConverterContext.getWebObject() instanceof IContextProvider) {
fs = ((IContextProvider) dataConverterContext.getWebObject()).getDataConverterContext().getApplication().getFlattenedSolution();
if (((IContextProvider) dataConverterContext.getWebObject()).getDataConverterContext().getForm() != null) {
form = ((IContextProvider) dataConverterContext.getWebObject()).getDataConverterContext().getForm().getForm();
}
}
return toJSON(writer, key, object, pd, clientConversion, fe, fs, form);
}
use of com.servoy.j2db.server.ngclient.WebFormComponent in project servoy-client by Servoy.
the class ComponentTypeSabloValue method detach.
@Override
public void detach() {
// already detached or nothing to clean up.
if (webObjectContext == null)
return;
if (forFoundsetPropertyListener != null) {
webObjectContext.removePropertyChangeListener(forFoundsetTypedPropertyName, forFoundsetPropertyListener);
FoundsetTypeSabloValue foundsetPropValue = getFoundsetValue();
if (foundsetPropValue != null) {
if (foundsetStateChangeListener != null) {
foundsetPropValue.removeStateChangeListener(foundsetStateChangeListener);
foundsetStateChangeListener = null;
}
if (viewPortChangeMonitor != null) {
foundsetPropValue.removeViewportDataChangeMonitor(viewPortChangeMonitor);
viewPortChangeMonitor = null;
}
if (dataLinkedPropertyRegistrationListener != null) {
FoundsetDataAdapterList dal = foundsetPropValue.getDataAdapterList();
if (dal != null)
dal.removeDataLinkedPropertyRegistrationListener(dataLinkedPropertyRegistrationListener);
}
foundsetPropValue.setRecordDataLinkedPropertyIDToColumnDP(childComponent.getName(), null);
}
}
if (readonlyPropertyListener != null)
webObjectContext.removePropertyChangeListener(WebFormUI.READONLY, readonlyPropertyListener);
// unregister this component from formcontroller "elements" scope if needed
WebFormComponent parentComponent = getParentComponent();
IWebFormUI formUI = parentComponent != null ? parentComponent.findParent(IWebFormUI.class) : null;
if (formUI != null && componentPropertyDescription != null && Utils.getAsBoolean(componentPropertyDescription.getTag(TAG_ADD_TO_ELEMENTS_SCOPE))) {
formUI.removeComponentFromElementsScope(formElementValue.element, formElementValue.element.getWebComponentSpec(), childComponent);
}
if (childComponent != null) {
childComponent.dispose();
childComponent = null;
}
componentIsCreated = false;
// reset to form element's record based properties or null
initRecordBasedProperties();
this.monitor = null;
this.webObjectContext = null;
}
use of com.servoy.j2db.server.ngclient.WebFormComponent in project servoy-client by Servoy.
the class FormComponentPropertyType method toSabloComponentValue.
@Override
public Object toSabloComponentValue(Object formElementValue, PropertyDescription pd, INGFormElement formElement, WebFormComponent component, DataAdapterList dataAdapterList) {
Form form = getForm(formElementValue, dataAdapterList.getApplication().getFlattenedSolution());
if (form != null) {
if (pd.getConfig() instanceof ComponentTypeConfig && ((ComponentTypeConfig) pd.getConfig()).forFoundset != null) {
return new FormComponentSabloValue(formElement, (JSONObject) formElementValue, pd, dataAdapterList, component, form);
} else {
FormComponentCache formComponentCache = FormElementHelper.INSTANCE.getFormComponentCache(formElement, pd, (JSONObject) formElementValue, form, dataAdapterList.getApplication().getFlattenedSolution());
List<FormElement> elements = formComponentCache.getFormComponentElements();
IWebFormUI formUI = component.findParent(IWebFormUI.class);
for (FormElement element : elements) {
WebFormComponent child = ComponentFactory.createComponent(dataAdapterList.getApplication(), dataAdapterList, element, component.getParent(), dataAdapterList.getForm().getForm());
formUI.contributeComponentToElementsScope(element, element.getWebComponentSpec(), child);
}
}
}
return formElementValue;
}
Aggregations