如何在 JBoss Portal 2.5.4 中将信息从 servlet 获取到 portlet

发布于 2024-07-13 21:08:51 字数 593 浏览 13 评论 0原文

我有一个基于 JBoss Portal 2.5.4 构建的门户,需要一些 I18N。 在login.jsp 页面(位于portal-server.war 中)上,我们添加了语言切换。 该页面上的链接之一是“忘记密码”功能。

出于与外观相关的原因,ForgetPassword 页面在我们的 JBoss Portal 中实现为最大化的 portlet。 但是,显然,还没有用户对象,因为还没有登录。

那么如何将用户在 login.jsp 上选择的区域设置信息传递到忘记密码 jsp 中呢?

我尝试过:

  • 会话变量(不行,它们不会跨越战争)
  • cookies(JBoss Portal 吞掉它们)
  • URL 参数(JBoss Portal 也吞掉它们)
  • System.setProperty() - 当它们到达 ForgetPassword 时jsp,它们被重置。

这一切都在 Windows Vista 或 2003 上运行。

我是否缺少一些明显的技术? 我是否只需要硬着头皮将 ForgetPassword 页面重新组织为 servlet,以便获取 URL 参数?

I have a portal built on JBoss Portal 2.5.4 that needs to have some I18N. On the login.jsp page (which is in portal-server.war), we added a language switch. One of the links on the page is to the Forget Password facility.

For reasons related to look-and-feel, the ForgetPassword page is implemented as a maximized portlet inside our JBoss Portal. But, obviously, there's no user object yet, since there hasn't been a login.

So how do I pass the locale information that the user selects on the login.jsp down into the Forget Password jsp?

I've tried:

  • session variables (no go, they don't cross over the wars)
  • cookies (JBoss Portal swallows them)
  • URL parameters (JBoss Portal swallows them too)
  • System.setProperty() - by the time they get to the ForgetPassword jsp, they're reset.

This is all running on Windows Vista or 2003.

Is there some obvious technique I'm missing? Do I just need to bite the bullet and reorganize my ForgetPassword page as a servlet so I can get URL parameters?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧时浪漫 2024-07-20 21:08:51

好吧,我找到了一种机制来做到这一点 - 在portal-object.xml中创建一个新的portlet窗口(ForgotPasswordWindow_de):

<window>
    <window-name>ForgotPasswordWindow_de</window-name>
    <instance-ref>UserMgmtPortletInstance_de</instance-ref>
    <region>center</region>
<height>0</height>
</window>

它指向portlet-instances.xml中的一个新的portlet实例(UserMgmtPortletInstance_de),它指向同一个Portlet,定义的语言首选项。

<deployments>
   <deployment>
        <instance>
           <instance-id>UserMgmtPortletInstance</instance-id>
           <portlet-ref>UserMgmtPortlet</portlet-ref>
           <preferences>
            <preference>
                <name>lang</name>
                <value>en</value>
                <read-only>true</read-only>
            </preference>
           </preferences>
          <security-constraint>
              <policy-permission>     
                <unchecked/>                
                 <action-name>view</action-name>
              </policy-permission>
           </security-constraint>
        </instance>
   </deployment>
   <!-- add new deployment for UserMgmtPortletInstance_de -->
   <deployment>
        <instance>
           <instance-id>UserMgmtPortletInstance_de</instance-id>
           <portlet-ref>UserMgmtPortlet</portlet-ref>
           <preferences>
            <preference>
                <name>lang</name>
                <value>de</value>
                <read-only>true</read-only>
            </preference>
           </preferences>
          <security-constraint>
              <policy-permission>     
                <unchecked/>                
                 <action-name>view</action-name>
              </policy-permission>
           </security-constraint>
        </instance>
   </deployment>
</deployments>

然后,在 Portlet doView() 代码中,我找到此首选项,并设置一个属性。

    String lang = request.getPreferences().getValue("lang", null);

    request.setAttribute("lang", lang);

然后,在 jsp 中,我查看属性并设置区域设置。

String locale = (String) request.getAttribute("lang");

首先,登录页面有一个开关,如果语言是德语,它会调用 ForgotPasswordWindow_de 而不是 ForgotPasswordWindow_en

Ok, I found one mechanism to do this - create a new portlet window (ForgotPasswordWindow_de) in portal-object.xml:

<window>
    <window-name>ForgotPasswordWindow_de</window-name>
    <instance-ref>UserMgmtPortletInstance_de</instance-ref>
    <region>center</region>
<height>0</height>
</window>

which points to a new portlet instance (UserMgmtPortletInstance_de) in portlet-instances.xml, which pointed to the same Portlet, with a lang preference defined.

<deployments>
   <deployment>
        <instance>
           <instance-id>UserMgmtPortletInstance</instance-id>
           <portlet-ref>UserMgmtPortlet</portlet-ref>
           <preferences>
            <preference>
                <name>lang</name>
                <value>en</value>
                <read-only>true</read-only>
            </preference>
           </preferences>
          <security-constraint>
              <policy-permission>     
                <unchecked/>                
                 <action-name>view</action-name>
              </policy-permission>
           </security-constraint>
        </instance>
   </deployment>
   <!-- add new deployment for UserMgmtPortletInstance_de -->
   <deployment>
        <instance>
           <instance-id>UserMgmtPortletInstance_de</instance-id>
           <portlet-ref>UserMgmtPortlet</portlet-ref>
           <preferences>
            <preference>
                <name>lang</name>
                <value>de</value>
                <read-only>true</read-only>
            </preference>
           </preferences>
          <security-constraint>
              <policy-permission>     
                <unchecked/>                
                 <action-name>view</action-name>
              </policy-permission>
           </security-constraint>
        </instance>
   </deployment>
</deployments>

Then, in the Portlet doView() code, I find this preference, and set an attribute.

    String lang = request.getPreferences().getValue("lang", null);

    request.setAttribute("lang", lang);

Then, in the jsp, I look at the attribute, and set the locale.

String locale = (String) request.getAttribute("lang");

And to kick it all off, the login page has a switch, and if the language is german, it calls ForgotPasswordWindow_de instead of ForgotPasswordWindow_en

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文