. 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

@@ -968,12 +968,23 @@ public final class Node implements Serializable, Scopeable
{ {
// TODO: add code here to use the dictionary and convert to correct value type // TODO: add code here to use the dictionary and convert to correct value type
Object javaObj = Context.jsToJava(value, Date.class); Object javaObj = Context.jsToJava(value, Date.class);
if (javaObj instanceof Date) if (javaObj instanceof Serializable)
{ {
value = (Date)javaObj; 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; return value;
} }

View File

@@ -37,9 +37,9 @@ import org.alfresco.service.cmr.repository.TemplateImageResolver;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.mozilla.javascript.Context; import org.mozilla.javascript.Context;
import org.mozilla.javascript.NativeJavaObject;
import org.mozilla.javascript.Scriptable; import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject; import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.Wrapper;
/** /**
* Implementation of the ScriptService using the Rhino JavaScript engine. * 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); Object result = cx.evaluateReader(scope, reader, "AlfrescoScript", 1, null);
// extract java object result if wrapped by rhinoscript // 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; return result;