如果客户端状态丢失,则 ADF / WCP 弹出

ADF / WCP Popup if client state is lost

我正在使用 JDev 11.1.1.7.0、WCP 11.1.1.8.0,我正在尝试覆盖视图状态丢失时显示的弹出窗口中的以下内容(当您为 CLIENT_STATE_MAX_TOKENS 小于消耗的视图状态数):

Because of inactivity, your session has timed out and is no longer active. Click OK to reload the page.

为此,我在浏览器中检查了 AdfDhtmlLookAndFeel.__TRANSLATIONS 中的值,发现 MSGPPRViewExpired 是上述消息的键。在我的皮肤包中,我为 MSGPPRViewExpired 指定了一个新值,并且可以在浏览器调试器中看到该值。然而,当弹出窗口出现时,它仍然显示旧消息。

更新 1 - 还反编译了 oracle.adfinternal.view.faces.renderkit.rich.resource.RichBundle 并且它有 MSGPPRViewExpired 作为密钥。不确定为什么弹出窗口仍然显示默认文本。

更新 2- 也试过这个 -

    FacesContext facesContext = phaseEvent.getFacesContext();
    HttpServletResponse res = (HttpServletResponse) facesContext.getExternalContext().getResponse();
    try {
        res.getWriter().write("<script>AdfDhtmlLookAndFeel.__TRANSLATIONS['MSGPPRViewExpired']='Sorry.. Something went wrong, we are gonna have to reload the page'</script>");
    } catch (IOException e) {
        //handle
    }

在相位监听器 (ANY_PHASE) 的 beforePhaseafterPhase 中。它还会更新消息并可以在控制台中看到,但弹出窗口仍显示默认文本。

我不是 100% 确定,但看起来这条消息与您当前的皮肤捆绑在一起。所以你所需要的就是覆盖皮肤消息包并用这个键写你自己的消息 MSGPPRViewExpired.

在你的皮肤中创建资源文件。 像这样在 trinindad-skins.xml 中注册这个包:

<bundle-name>resources.skinBundle</bundle-name>

取决于捆绑包的类型使用 MSGPPRViewExpired 键和所需文本创建适当的记录。

实际上,这条消息的右键似乎是:

af_document.POST_SESSION_TIMEOUT_ALERT_TITLE
af_document.POST_SESSION_TIMEOUT_MSG
af_document.POST_SESSION_TIMEOUT_MSG_CONTINUE

这里还有更多此类消息的键:

af_document.PRE_SESSION_TIMEOUT_MSG
af_document.PRE_SESSION_TIMEOUT_MSG_SECOND
af_document.PRE_SESSION_TIMEOUT_CONFIRM_TITLE

所以如果有人遇到同样的问题,这里是解决方案,不是很推荐,但据我所知这是唯一的方法 -

某些键如 MSGPPRViewExpired 不能直接自定义,所以要走的路是为您的语言环境覆盖默认值 RichBundle。例如,在 faces-config 中添加 en 作为您支持的语言环境,然后指定类似这样的内容 -

    package oracle.adfinternal.view.faces.renderkit.rich.resource;

    import java.util.ListResourceBundle;

    public class RichBundle_en extends ListResourceBundle {


        @Override
        public Object[][] getContents() {
            return new Object[][] { { "MSGPPRViewExpired", "Boom! New Message!" } };
        }
    }

繁荣。

@Nagh,感谢您的所有建议。

此致