简体   繁体   English

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

[英]Adempiere 380 Webui doesn't show popup for process error message and on complete error messages

I am using adempiere 380 webui, i would like to show error message on any failure of adempiere process or onComplete of any document.我正在使用 adempiere 380 webui,我想在任何 adempiere 进程失败或任何文档的 onComplete 上显示错误消息。

The code which i have written to show error popup working in desktop application.我编写的代码显示在桌面应用程序中工作的错误弹出窗口。 But in webui - jboss it printing in console of jboss.但是在 webui - jboss 中,它在 jboss 的控制台中打印。

I have accomplished this using AbstractADWindowPanel.java where i am checking process id or table then execute particular code in that and if error codition is true then i am displaying FDialog.ask("Print Message");我已经使用 AbstractADWindowPanel.java 完成了这项工作,我正在检查进程 ID 或表,然后在其中执行特定代码,如果错误代码为真,那么我将显示 FDialog.ask("Print Message"); . .

Is there any generic way to do this by which it can be used for all classes.是否有任何通用方法可以将其用于所有类。

Since processes can be fully automated and run on the server, your code needs to be aware of the GUI being used so that the correct dialog script can be called.由于流程可以完全自动化并在服务器上运行,因此您的代码需要了解正在使用的 GUI,以便可以调用正确的对话框脚本。 There are three options, a server process (no dialog), swing (ADialog) or ZK (FDialog).有三个选项,一个服务器进程(无对话框),swing(ADialog)或ZK(FDialog)。 Generally, its discouraged to use dialogs in this way.通常,不鼓励以这种方式使用对话框。 Certainly, you wouldn't want a server process to block waiting for user input.当然,您不希望服务器进程阻塞等待用户输入。 But, if you know what your doing and really need to...但是,如果您知道自己在做什么并且真正需要...

In the most recent releases, the process code includes a flag that tests which of the states its in so it can display errors.在最新版本中,流程代码包含一个标志,用于测试其处于哪些状态,以便显示错误。 An example of how this is used is with the Migration Script saves to XML format.如何使用此功能的一个示例是将迁移脚本保存为 XML 格式。 In the process, the GUI info is used to open the correct file dialog in swing or, in ZK, pass the request to the browser.在此过程中,GUI 信息用于在 swing 中打开正确的文件对话框,或者在 ZK 中将请求传递给浏览器。

Here is a snippet of how it works from ProcessInfo.java in the current release这是当前版本中 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);
    }
}

The call to setInterfaceType() is made when the process is launched by the ProcessModalDialog in swing or the AbstractZKForm or ProcessPanel in zk.当进程由 swing 中的ProcessModalDialog或 zk 中的AbstractZKFormProcessPanel启动时,会调用setInterfaceType()

For other processes, the value is set by the AbstractFormController which is used by both interfaces.对于其他进程,该值由两个接口使用的AbstractFormController设置。 If the interface type is not set the loadProcessInfo method will try to figure it out as follows:如果未设置接口类型,则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);
    }

Finally, this can be used to control the dialogs within your process with a call similar to最后,这可用于控制进程中的对话框,调用类似于

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM