. Fix to Alfresco JavaScript to correctly convert back multi-value list properties that have not been modified

. Change to use of Wrapper interface when returning Java values from JavaScript
. Addition of final 1.4 icons from Linton for Dashboard and User Options screens

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3492 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-08-14 10:56:18 +00:00
parent 40286bdad8
commit 50ab6661c4
2 changed files with 38 additions and 27 deletions

View File

@@ -945,35 +945,46 @@ public final class Node implements Serializable, Scopeable
if (value instanceof NativeArray)
{
// convert JavaScript array of values to a List of Serializable objects
Object[] propIds = values.getIds();
List<Serializable> propValues = new ArrayList<Serializable>(propIds.length);
for (int i=0; i<propIds.length; i++)
{
// work on each key in turn
Object propId = propIds[i];
// convert JavaScript array of values to a List of Serializable objects
Object[] propIds = values.getIds();
List<Serializable> propValues = new ArrayList<Serializable>(propIds.length);
for (int i=0; i<propIds.length; i++)
{
// work on each key in turn
Object propId = propIds[i];
// we are only interested in keys that indicate a list of values
if (propId instanceof Integer)
{
// get the value out for the specified key
Serializable val = (Serializable)values.get((Integer)propId, values);
// recursively call this method to convert the value
propValues.add(convertValueForRepo(val));
}
}
value = (Serializable)propValues;
// we are only interested in keys that indicate a list of values
if (propId instanceof Integer)
{
// get the value out for the specified key
Serializable val = (Serializable)values.get((Integer)propId, values);
// recursively call this method to convert the value
propValues.add(convertValueForRepo(val));
}
}
value = (Serializable)propValues;
}
else
{
// TODO: add code here to use the dictionary and convert to correct value type
Object javaObj = Context.jsToJava(value, Date.class);
if (javaObj instanceof Date)
{
value = (Date)javaObj;
}
// TODO: add code here to use the dictionary and convert to correct value type
Object javaObj = Context.jsToJava(value, Date.class);
if (javaObj instanceof Serializable)
{
value = (Serializable)javaObj;
}
}
}
else if (value instanceof Serializable[])
{
// convert back a list of Java values
Serializable[] array = (Serializable[])value;
ArrayList<Serializable> list = new ArrayList<Serializable>(array.length);
for (int i=0; i<array.length; i++)
{
list.add(convertValueForRepo(array[i]));
}
value = list;
}
return value;
}

View File

@@ -37,9 +37,9 @@ import org.alfresco.service.cmr.repository.TemplateImageResolver;
import org.alfresco.service.namespace.QName;
import org.apache.log4j.Logger;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.NativeJavaObject;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.Wrapper;
/**
* Implementation of the ScriptService using the Rhino JavaScript engine.
@@ -250,9 +250,9 @@ public class RhinoScriptService implements ScriptService
Object result = cx.evaluateReader(scope, reader, "AlfrescoScript", 1, null);
// extract java object result if wrapped by rhinoscript
if (result != null && result instanceof NativeJavaObject)
if (result instanceof Wrapper)
{
result = Context.jsToJava(result, Object.class);
result = ((Wrapper)result).unwrap();
}
return result;