It's all about the answers!

Ask a question

Rhino x Dojo - problem


Fausto Lemos (16811518) | asked Nov 16 '11, 3:35 p.m.
Hi,

i'm building a generic validator with javascript and realize that he works fine at web ui but crashs at eclipse client.

dojo.provide("com.test.alm.DateComparator");


dojo.require("com.ibm.team.workitem.api.common.Status");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("com.ibm.team.workitem.api.common.Severity");
dojo.require("dojo.date");
dojo.require("dojo.date.stamp");

(function() {
var Severity= com.ibm.team.workitem.api.common.Severity;
var Status= com.ibm.team.workitem.api.common.Status;
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;

var DateComparator = dojo.declare("com.test.alm.DateComparator", null, {

validate: function(attributeId, workItem, configuration) {
var startDate = workItem.getAttribute(attributeId); //ECLIPSE CLIENT CRASHS HERE!!!
var endDate = workItem.getValue(startDate._attribute.dependentAttributes[0]);
startDate = workItem.getValue(attributeId);

if (startDate != null && endDate != null) {
startDate = dojo.date.stamp.fromISOString(startDate);
endDate = dojo.date.stamp.fromISOString(endDate);
if (dojo.date.compare(endDate, startDate) <= 0) {
return new Status(Severity["ERROR"], "Invalid date!");
}
}

return Status.OK_STATUS;
}
});
})();


I get the following stack at log:

org.mozilla.javascript.EcmaError: TypeError: Cannot find function getAttribute in object . (test.js#17)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3557)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3535)
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3563)
at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3582)
at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3646)
at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2186)
at org.mozilla.javascript.gen.c35._c2(teste.js:17)
at org.mozilla.javascript.gen.c35.call(teste.js)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3003)
at org.mozilla.javascript.gen.c35.call(teste.js)
at com.ibm.team.rtc.common.scriptengine.internal.bridge.proxy.AbstractInvocationHandler$MethodHandler$1.run(AbstractInvocationHandler.java:160)
at com.ibm.team.rtc.common.scriptengine.environment.AbstractScriptEnvironment.execute(AbstractScriptEnvironment.java:74)
at com.ibm.team.rtc.common.scriptengine.internal.bridge.proxy.AbstractInvocationHandler$MethodHandler.invoke(AbstractInvocationHandler.java:156)
at com.ibm.team.rtc.common.scriptengine.internal.bridge.proxy.AbstractInvocationHandler.invokeGeneric(AbstractInvocationHandler.java:141)
at com.ibm.team.rtc.common.scriptengine.internal.bridge.proxy.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:95)
at $Proxy44.validate(Unknown Source)
at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.validate(ScriptAttributeValueProvider.java:79)
at com.ibm.team.workitem.common.internal.attributeValueProviders.AttributeValueProviderRegistry$SafeValidator.validate(AttributeValueProviderRegistry.java:123)
at com.ibm.team.workitem.common.internal.model.impl.AttributeImpl.validate(AttributeImpl.java:923)
at sun.reflect.GeneratedMethodAccessor81.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at com.ibm.team.repository.common.internal.util.ItemStore$ItemInvocationHandler.invoke(ItemStore.java:597)
at $Proxy21.validate(Unknown Source)
at com.ibm.team.workitem.client.internal.util.WorkItemEventResolver$InternalBackgroundJob.resolve(WorkItemEventResolver.java:265)
at com.ibm.team.workitem.client.internal.util.WorkItemEventResolver$InternalBackgroundJob.runProtected(WorkItemEventResolver.java:93)
at com.ibm.team.foundation.client.util.FoundationJob.run(FoundationJob.java:68)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)


My question is: there is a chance that rhino is massing up the validation? or some libraries mismatch (dojo used at web ui x dojo used by rhino)?

tks!

Comments
rajesh uppiliappan commented Apr 16 '13, 5:03 a.m.

Hi,
I'm not here to answer your question, but rather I would like to ask you one question. How to configure the dojo to run in java via Rhino. Please provide me wiht a sample code. Im using dojo 1.8.0


Fausto Lemos commented Apr 16 '13, 9:15 a.m.

https://developer.mozilla.org/en-US/docs/Rhino_documentation

Be the first one to answer this question!


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.