use of com.servoy.j2db.server.headlessclient.WebClientsApplication in project servoy-client by Servoy.
the class DebugClientHandler method executeMethod.
/**
* @param persist
* @param elementName
*/
public void executeMethod(final ISupportChilds persist, final String scopeName, final String methodname) {
final IApplication serviceProvider = getDebugReadyClient();
if (serviceProvider != null) {
final Runnable run = new Runnable() {
public void run() {
if (persist instanceof Solution) {
try {
serviceProvider.getScriptEngine().getScopesScope().executeGlobalFunction(scopeName, methodname, null, false, false);
} catch (Exception e) {
Debug.log(e);
}
} else if (persist instanceof Form) {
try {
IFormController fp = serviceProvider.getFormManager().leaseFormPanel(((Form) persist).getName());
if (fp != null) {
fp.initForJSUsage();
fp.setView(fp.getView());
fp.executeOnLoadMethod();
fp.executeFunction(methodname, null, false, null, false, null);
}
} catch (Exception e) {
Debug.log(e);
}
}
}
};
if (serviceProvider == getDebugHeadlessClient() || serviceProvider == getDebugAuthenticator()) {
ApplicationServerRegistry.get().getExecutor().execute(new Runnable() {
public void run() {
serviceProvider.invokeLater(run);
}
});
} else if (serviceProvider == getDebugWebClient()) {
ApplicationServerRegistry.get().getExecutor().execute(new Runnable() {
public void run() {
RequestCycle rc = null;
try {
// fake a request as much as possible
WebClientsApplication fakeApplication = ((WebClient) serviceProvider).getFakeApplication();
Application.set(fakeApplication);
rc = new WebRequestCycle(fakeApplication, new EmptyRequest(), new WebResponse());
serviceProvider.invokeAndWait(run);
} finally {
Application.unset();
rc.detach();
}
}
});
} else {
serviceProvider.invokeLater(run);
}
}
}
Aggregations