Search in sources :

Example 1 with IRhinoDesignConverter

use of com.servoy.j2db.util.IRhinoDesignConverter in project servoy-client by Servoy.

the class JSNGWebComponent method fromRhinoToDesignValue.

public static Object fromRhinoToDesignValue(Object value, PropertyDescription pd, IApplication application, JSWebComponent webComponent, String propertyName) {
    Object result = null;
    if (pd != null && pd.getType() instanceof IFormComponentType) {
        String firstPart = propertyName;
        int i = firstPart.indexOf('.');
        if (i > 0) {
            firstPart = firstPart.substring(0, i);
        }
        IFormComponentRhinoConverter converter = ((IFormComponentType) pd.getType()).getFormComponentRhinoConverter(firstPart, webComponent.getBaseComponent(true).getProperty(firstPart), application, webComponent);
        result = converter.setRhinoToDesignValue(firstPart == propertyName ? "" : propertyName.substring(firstPart.length() + 1), value);
    } else if (pd != null && pd.getType() instanceof IRhinoDesignConverter) {
        result = ((IRhinoDesignConverter) pd.getType()).fromRhinoToDesignValue(value, pd, application, webComponent);
    } else {
        result = JSWebComponent.defaultRhinoToDesignValue(value, application);
    }
    return result;
}
Also used : IFormComponentRhinoConverter(com.servoy.j2db.util.IFormComponentRhinoConverter) JSONObject(org.json.JSONObject) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) IRhinoDesignConverter(com.servoy.j2db.util.IRhinoDesignConverter) IFormComponentType(com.servoy.j2db.util.IFormComponentType)

Example 2 with IRhinoDesignConverter

use of com.servoy.j2db.util.IRhinoDesignConverter in project servoy-client by Servoy.

the class JSNGWebComponent method fromDesignToRhinoValue.

public static Object fromDesignToRhinoValue(Object value, PropertyDescription pd, IApplication application, JSWebComponent webComponent, String propertyName) {
    Object result = value;
    if (pd != null && pd.getType() instanceof IFormComponentType) {
        String firstPart = propertyName;
        int i = firstPart.indexOf('.');
        if (i > 0) {
            firstPart = firstPart.substring(0, i);
        }
        IFormComponentRhinoConverter converter = ((IFormComponentType) pd.getType()).getFormComponentRhinoConverter(firstPart, value, application, webComponent);
        result = converter.getDesignToRhinoValue(firstPart == propertyName ? "" : propertyName.substring(firstPart.length() + 1));
    } else if (pd != null && pd.getType() instanceof IRhinoDesignConverter) {
        result = ((IRhinoDesignConverter) pd.getType()).fromDesignToRhinoValue(value, pd, application, webComponent);
    }
    return result == null ? Context.getUndefinedValue() : ServoyJSONObject.jsonNullToNull(result);
}
Also used : IFormComponentRhinoConverter(com.servoy.j2db.util.IFormComponentRhinoConverter) JSONObject(org.json.JSONObject) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) IRhinoDesignConverter(com.servoy.j2db.util.IRhinoDesignConverter) IFormComponentType(com.servoy.j2db.util.IFormComponentType)

Aggregations

IFormComponentRhinoConverter (com.servoy.j2db.util.IFormComponentRhinoConverter)2 IFormComponentType (com.servoy.j2db.util.IFormComponentType)2 IRhinoDesignConverter (com.servoy.j2db.util.IRhinoDesignConverter)2 ServoyJSONObject (com.servoy.j2db.util.ServoyJSONObject)2 JSONObject (org.json.JSONObject)2