我正在使用adempiere 380 webui,我想在adempiere进程失败或任何文档的onComplete上显示错误消息。
我编写的用于显示在桌面应用程序中工作的错误弹出窗口的代码。但是在webui-jboss中,它在jboss的控制台中打印。
我已使用AbstractADWindowPanel.java完成此操作,其中我正在检查进程ID或表,然后在其中执行特定代码,并且如果错误编码为true,则显示FDialog.ask(“ Print Message”); 。
有没有通用的方法可以将其用于所有类。
答案 0 :(得分:1)
由于过程可以完全自动化并且可以在服务器上运行,因此您的代码需要知道所使用的GUI,以便可以调用正确的对话框脚本。有三个选项,一个服务器进程(无对话框),swing(ADialog)或ZK(FDialog)。通常,不鼓励以这种方式使用对话框。当然,您不希望服务器进程阻塞等待用户输入的过程。但是,如果您知道自己在做什么,并且真的需要...
在最新版本中,过程代码包括一个标志,用于测试其处于哪个状态,以便可以显示错误。迁移脚本保存为XML格式的一个示例。在此过程中,GUI信息可用来打开正确的文件对话框,或者在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);
}
}
由setInterfaceType()
或zk的ProcessModalDialog
或AbstractZKForm
启动该过程时,将调用ProcessPanel
。
对于其他进程,该值由两个接口使用的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 ...