‎10-07-2012 10:09 AM
Hello,
I want initialize and refresh documents using Java API.
I have a MegaCollection with my documents.
MegaCollection listDocs = mgRoot.getSelection("Select [Document]", "Nom");
for (MegaObject oSelection : listDocs) {
// reinitialize and refresh document
}
Which method use to refresh document.
In VB this code works
oSelection.InitializeDocument oSelection.RefreshDocument
but I don't know call this method in java.
Thanks for the response.
--
N. Gibanel
Solved! Go to Solution.
‎11-07-2012 04:04 PM
Unfortunately, the RTF documents are pretty slow in general.
Thus, this script is the best you can do to refresh automatically several documents.
‎11-07-2012 03:53 PM
Document refresh takes considerable time (it's longer than manually).
Maybe an optimization of this script ? I don't know.
‎11-07-2012 03:40 PM
I'm glad to know that it works
After a quick look in VB's documentation, the function doEvents is used to force the application to yield its processor use for one cycle, so it might slow down a bit your loop.
So what do you mean by "improving the performance" ? Do you want to improve your loop's speed?
‎11-07-2012 03:17 PM
Ok it's work.
Is there a way to improve performance? (for example doEvent in VB)
Thanks for your help.
--
N. Gibanel
‎10-07-2012 05:42 PM
My bad, the error probably comes from the fact that the method signature includes an "arg" attribute that I didn't set in the sample code I gave you.
This would probably be better :
MegaCollection listDocs = mgRoot.getSelection("Select[Document]","Nom"); for(MegaObject oSelection : listDocs) { oSelection.callMethod("InitializeDocument",null); oSelection.callMethod("RefreshDocument",null); }
‎10-07-2012 04:59 PM
Thanks but it doesn't work...
I have this error :
Exception in thread "main" com.mega.modeling.api.MegaException: MEGA Error 1 at com.mega.modeling.api.jni.MappModuleJNI.InvokeMethod(Native Method) at com.mega.modeling.api.jni.ComObjectProxy.invokeMethod(Unknown Source)
‎10-07-2012 03:04 PM
Hi,
Usually, when you know the method in VB, and its equivalent doesn't exist in the Java API, you can use the method callMethod(Object name, Object ... arg) if there's no return or the function callFunction(Object name, Object ... arg) if there's a return.
For you problem, it would probably be something like :
MegaCollection listDocs = mgRoot.getSelection("Select[Document]","Nom"); for(MegaObject oSelection : listDocs) { oSelection.callMethod("InitializeDocument"); oSelection.callMethod("RefreshDocument"); }
This would probably work.
I hope it helps,
Regards