use of com.servoy.j2db.server.ngclient.property.types.NGConversions.ISabloComponentToRhino in project servoy-client by Servoy.
the class RuntimeWebComponent method put.
@Override
public void put(String name, Scriptable start, Object value) {
if (isInvalidValue(name, value))
return;
List<Pair<String, String>> oldVisibleForms = getVisibleForms();
if (specProperties != null && specProperties.contains(name)) {
Object previousVal = null;
PropertyDescription pd = webComponentSpec.getProperties().get(name);
if (pd.getType() instanceof ISabloComponentToRhino && !(pd.getType() instanceof IRhinoToSabloComponent)) {
// the it has sablo to rhino conversion but not the other way around then we should just use the
// value from the conversion so call get(String,Scriptable)
previousVal = get(name, start);
} else
previousVal = component.getProperty(name);
Object val = NGConversions.INSTANCE.convertRhinoToSabloComponentValue(value, previousVal, pd, component);
if (val != previousVal)
component.setProperty(name, val);
if (pd != null && pd.getType() instanceof VisiblePropertyType) {
// search all labelfor elements
for (WebComponent siblingComponent : component.getParent().getComponents()) {
Collection<PropertyDescription> labelFors = siblingComponent.getSpecification().getProperties(LabelForPropertyType.INSTANCE);
if (labelFors != null) {
for (PropertyDescription labelForProperty : labelFors) {
if (Utils.equalObjects(component.getName(), siblingComponent.getProperty(labelForProperty.getName()))) {
// sibling component is labelfor, so set value to all its visible properties
Collection<PropertyDescription> visibleProperties = siblingComponent.getSpecification().getProperties(VisiblePropertyType.INSTANCE);
if (visibleProperties != null) {
for (PropertyDescription visibleProperty : visibleProperties) {
previousVal = siblingComponent.getProperty(visibleProperty.getName());
val = NGConversions.INSTANCE.convertRhinoToSabloComponentValue(value, previousVal, visibleProperty, siblingComponent);
if (val != previousVal)
siblingComponent.setProperty(name, val);
}
}
break;
}
}
}
}
}
} else if (prototypeScope != null) {
if (!apiFunctions.containsKey(name)) {
// check if we have a setter for this property
if (name != null && name.length() > 0) {
String uName = new StringBuffer(name.substring(0, 1).toUpperCase()).append(name.substring(1)).toString();
if (apiFunctions.containsKey("set" + uName) && apiFunctions.containsKey("get" + uName)) {
// call setter
Function propertySetter = apiFunctions.get("set" + uName);
propertySetter.call(Context.getCurrentContext(), start, start, new Object[] { value });
} else {
prototypeScope.put(name, start, value);
}
}
}
}
updateVisibleContainers(oldVisibleForms);
}
use of com.servoy.j2db.server.ngclient.property.types.NGConversions.ISabloComponentToRhino in project servoy-client by Servoy.
the class WebServiceScriptable method getIds.
@Override
public Object[] getIds() {
ArrayList<String> al = new ArrayList<>();
IWebObjectContext service = null;
if (application != null) {
service = (IWebObjectContext) application.getWebsocketSession().getClientService(serviceSpecification.getName());
}
for (String name : serviceSpecification.getAllPropertiesNames()) {
PropertyDescription pd = serviceSpecification.getProperty(name);
IPropertyType<?> type = pd.getType();
if (service == null || !(type instanceof ISabloComponentToRhino<?>) || ((ISabloComponentToRhino) type).isValueAvailableInRhino(service.getProperty(name), pd, service)) {
al.add(name);
}
}
al.addAll(serviceSpecification.getApiFunctions().keySet());
return al.toArray();
}
Aggregations