Adempiere 380 Webui 不显示进程错误消息和完整错误消息的弹出窗口



我使用的是adempiere 380 webui,我想在adempire进程的任何失败或任何文档的onComplete上显示错误消息。

我写的代码显示错误弹出在桌面应用程序中工作。但在webui-jboss中,它在jboss的控制台中打印。

我使用AbstractADWindowPanel.java完成了这项工作,在那里我检查进程id或表,然后执行其中的特定代码,如果错误编码为true,那么我将显示FDialog.aask("打印消息"(。

是否有任何通用的方法可以将其用于所有类。

由于进程可以完全自动化并在服务器上运行,因此您的代码需要了解正在使用的GUI,以便可以调用正确的对话框脚本。有三个选项,一个服务器进程(无对话框(、swing(ADialog(或ZK(FDialog(。一般来说,不鼓励以这种方式使用对话框。当然,您不希望服务器进程阻塞等待用户输入。但是,如果你知道自己在做什么,并且真的需要…

在最新的版本中,流程代码包括一个标志,用于测试哪个状态处于其中,以便显示错误。迁移脚本保存为XML格式就是如何使用此方法的一个示例。在此过程中,GUI信息用于在swing中打开正确的文件对话框,或者在ZK中,将请求传递给浏览器。

以下是当前版本中ProcessInfo.java的一个片段

/**
* Get the interface type this process is being run from.  The interface type
* can be used by the process to perform UI type actions from within the process
* or in the {@link #postProcess(boolean)}
* @return The InterfaceType which will be one of 
* <li> {@link #INTERFACE_TYPE_NOT_SET}
* <li> {@link #INTERFACE_TYPE_SWING} or
* <li> {@link #INTERFACE_TYPE_ZK}
*/
public String getInterfaceType() {
if (interfaceType == null || interfaceType.isEmpty())
interfaceType = INTERFACE_TYPE_NOT_SET;
return interfaceType;
}
/**
* Sets the Interface Type
* @param uiType which must equal one of the following: 
* <li> {@link #INTERFACE_TYPE_NOT_SET} (default)
* <li> {@link #INTERFACE_TYPE_SWING} or
* <li> {@link #INTERFACE_TYPE_ZK}
* The interface should be set by UI dialogs that start the process.
* @throws IllegalArgumentException if the interfaceType is not recognized.
*/
public void setInterfaceType(String uiType) {
// Limit value to known types
if (uiType.equals(INTERFACE_TYPE_NOT_SET)
||uiType.equals(INTERFACE_TYPE_ZK)
||uiType.equals(INTERFACE_TYPE_SWING) )
{
this.interfaceType = uiType;
}
else
{
throw new IllegalArgumentException("Unknown interface type " + uiType);
}
}

当进程由swing中的ProcessModalDialog或zk中的AbstractZKFormProcessPanel启动时,对setInterfaceType()进行调用。

对于其他进程,该值由两个接口都使用的AbstractFormController设置。如果没有设置接口类型,loadProcessInfo方法将尝试如下计算:

//  Determine the interface type being used.  Its set explicitly in the ProcessInfo data
//  but we will fallback to testing the stack trace in case it wasn't.  Note that the 
//  stack trace test may not be accurate as it depends on the calling class names.
//  TODO Also note that we are only testing for ZK or Swing.  If another UI is added, we'll 
//  have to fix this logic.
if (processInfo == null || processInfo.getInterfaceType().equals(ProcessInfo.INTERFACE_TYPE_NOT_SET))
{
// Need to know which interface is being used as the events may be different and the proper
// listeners have to be activated.  Test the calling stack trace for "webui".
// If not found, assume the SWING interface
isSwing = true;
StackTraceElement[] stElements = Thread.currentThread().getStackTrace();
for (int i=1; i<stElements.length; i++) {
StackTraceElement ste = stElements[i];
if (ste.getClassName().contains("webui")
|| ste.getClassName().contains("zk.ui")) {
isSwing  = false;
break;
}
}
log.warning("Process Info is null or interface type is not set. Testing isSwing = " + isSwing);
}
else 
{
isSwing = processInfo.getInterfaceType().equals(ProcessInfo.INTERFACE_TYPE_SWING);
}

最后,可以使用类似的调用来控制流程中的对话框

if (ProcessInfo.INTERFACE_TYPE_SWING.equals(this.getProcessInfo().getInterfaceType()))
{
... Do something on a swing...
}
else ...

相关内容

最新更新