use of com.servoy.j2db.server.ngclient.component.RuntimeWebGroup in project servoy-client by Servoy.
the class WebFormUI method contributeComponentToElementsScope.
private void contributeComponentToElementsScope(ElementScope elementsScope, FormElement fe, WebObjectSpecification componentSpec, WebFormComponent component) {
Object lengthOfEl = elementsScope.get("length", elementsScope);
int lastElementByIndex = (lengthOfEl instanceof Integer ? ((Integer) lengthOfEl).intValue() : 0);
if (!FormElement.ERROR_BEAN.equals(componentSpec.getName()) && (!fe.getName().startsWith("svy_") || ((fe.getPersistIfAvailable() instanceof IFormElement) && ((IFormElement) fe.getPersistIfAvailable()).getGroupID() != null))) {
RuntimeWebComponent runtimeComponent = new RuntimeWebComponent(component, componentSpec);
if (fe.isLegacy() || ((fe.getForm().getView() == IForm.LIST_VIEW || fe.getForm().getView() == FormController.LOCKED_LIST_VIEW || fe.getForm().getView() == FormController.TABLE_VIEW || fe.getForm().getView() == FormController.LOCKED_TABLE_VIEW) && fe.getTypeName().startsWith("servoydefault-"))) {
// add legacy behavior
runtimeComponent.setPrototype(new RuntimeLegacyComponent(component));
}
if (!fe.getName().startsWith("svy_")) {
elementsScope.put(fe.getRawName(), formController.getFormScope(), runtimeComponent);
elementsScope.put(lastElementByIndex, formController.getFormScope(), runtimeComponent);
}
String groupID = fe.getPersistIfAvailable() instanceof IFormElement ? ((IFormElement) fe.getPersistIfAvailable()).getGroupID() : null;
if (groupID != null) {
if (groups == null)
groups = new HashMap<String, RuntimeWebGroup>(4);
RuntimeWebGroup group = groups.get(groupID);
if (group == null) {
String groupName = FormElementGroup.getName(groupID);
group = new RuntimeWebGroup(groupName);
group.setParentScope(component.getDataConverterContext().getApplication().getScriptEngine().getSolutionScope());
elementsScope.put(groupName, formController.getFormScope(), group);
groups.put(groupID, group);
}
group.add(runtimeComponent);
}
}
}
use of com.servoy.j2db.server.ngclient.component.RuntimeWebGroup in project servoy-client by Servoy.
the class WebFormUI method removeComponentFromElementsScope.
// this should be the opposite of formUI.contributeComponentToElementsScope(...)
public void removeComponentFromElementsScope(FormElement fe, WebObjectSpecification componentSpec, WebFormComponent component) {
ElementScope elementsScope = getElementsScope();
if (elementsScope != null) {
if (!FormElement.ERROR_BEAN.equals(componentSpec.getName()) && (!fe.getName().startsWith("svy_") || ((fe.getPersistIfAvailable() instanceof IFormElement) && ((IFormElement) fe.getPersistIfAvailable()).getGroupID() != null))) {
if (!fe.getName().startsWith("svy_")) {
RuntimeWebComponent runtimeComponent = (RuntimeWebComponent) elementsScope.remove(fe.getRawName());
elementsScope.removeIndexByValue(runtimeComponent);
}
String groupID = fe.getPersistIfAvailable() instanceof IFormElement ? ((IFormElement) fe.getPersistIfAvailable()).getGroupID() : null;
if (groupID != null) {
if (groups == null)
groups = new HashMap<String, RuntimeWebGroup>(4);
RuntimeWebGroup group = groups.get(groupID);
if (group != null) {
String groupName = FormElementGroup.getName(groupID);
group.remove(component);
if (group.getComponentCount() == 0)
elementsScope.remove(groupName);
groups.remove(groupID);
}
}
}
} else {
Debug.error(new RuntimeException("Trying to remove component from a non-existent elements scope for form: " + getName()));
}
}
Aggregations