【问题标题】:Not able to navigate to another page on button in jsf portlet无法导航到 jsf portlet 中按钮上的另一个页面
【发布时间】:2012-04-30 18:46:18
【问题描述】:

我正在尝试开发一个 jsf portlet(primefaces 3.2)

我创建了一个 jsf portlet,我在其中显示一个数据表。在我的数据表内有一个按钮。

现在,当我单击该按钮时,应该会打开一个 jsp 页面。它实际上不起作用。

我正在尝试使用这种方式来实现它。

<div style="text-align:right">
                        <p:lightBox iframe="true" width="1000" height="840">
                            <h:outputLink
                             value="./next.jsp">
                                <p:commandButton value="Add" icon="ui-icon ui-icon-plusthick" style="margin:3px;display: table-cell;vertical-align: middle;"/>
                            </h:outputLink>
                        </p:lightBox>
                    </div>

我当前的 portletViewMode.xhtml(portlet 显示页面)和 next.jsp 存在于 portlet 中(在 xhtml 文件夹中)。

它是一个 jsf 视图(portletViewMode.xhtml),它在您创建 jsf-portlet 时创建,在该视图中我显示了一个数据表,里面有一个按钮。

当我单击该按钮时,我应该能够导航到充当灯箱的 jsp 页面。因此,如果我关闭,我应该能够看到我以前的 jsf 视图。

所以我试图在按钮(这是一个 jsf 组件)的操作上从 jsf 视图导航到另一个 jsp 页面。

我应该为此做些什么? 有没有人尝试过从 jsf 视图导航到任何其他页面?

【问题讨论】:

  • Primefaces 和 JSP 不能一起工作。因此,如果您在 next.jsp 上使用 Primefaces 组件,您可能会遇到问题。一般来说:为什么混合使用 JSP 和 facelets?使用一个另一个更可取的facelets。
  • 是的,我们也可以使用 xhtml 文件来代替 jsp 页面。我也尝试过这种方式。在 next.jsp 或 next.xhtml 中,我只是想简单地显示“hello world”。但我的基本问题是我无法导航。

标签: jsf-2 liferay-6


【解决方案1】:

您以错误的方式使用p:lightBox

关于 Primefaces 主页上的示例,您应该使用 p:lightBoxiframe="true" 来显示页面内容。

h:outputLink 包裹h:commandButton 并不是最优雅的解决方案。您可以使用简单的h:button,但也可以使用h:commandButton

<p:lightBox iframe="true">
    <h:outputLink value="page2.xhtml"  >  
        <h:commandButton action="#" value="Next page" />  
    </h:outputLink>  
</p:lightBox>

注意iFrame的内容需要进入h:outputLinkvalue属性中。

此外,JSP 和 Primefaces 将无法工作。仅使用 facelets。

【讨论】:

    猜你喜欢
    • 2015-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-19
    • 2010-10-08
    • 1970-01-01
    • 2020-09-02
    相关资源
    最近更新 更多