Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 部分呈现JSF组件_Java_Jsf_Richfaces - Fatal编程技术网

Java 部分呈现JSF组件

Java 部分呈现JSF组件,java,jsf,richfaces,Java,Jsf,Richfaces,详细介绍如何通过包含不同的源文件(带有面板和组件)进行局部渲染(div)。取决于菜单操作。如果正确理解JSF阶段,视图将在渲染响应(最后一个阶段)期间重建。如果我有事件和动作,它们将在调用应用程序阶段调用,之前的阶段 我只想在视图重新呈现之前,通过ajax为特定菜单命令设置包含xhtml页面。但是ui:include总是在菜单操作之前被调用。我尝试过RichFaces4(a4j:param、rich:panel等)和标准JSF2.0(f:param、h:panelGroup)组件,但是ui:in

详细介绍如何通过包含不同的源文件(带有面板和组件)进行局部渲染(div)。取决于菜单操作。如果正确理解JSF阶段,视图将在渲染响应(最后一个阶段)期间重建。如果我有事件和动作,它们将在调用应用程序阶段调用,之前的阶段

我只想在视图重新呈现之前,通过ajax为特定菜单命令设置包含xhtml页面。但是ui:include总是在菜单操作之前被调用。我尝试过RichFaces4(a4j:param、rich:panel等)和标准JSF2.0(f:param、h:panelGroup)组件,但是ui:include总是在操作之前被调用

在调用ui:include之前,我应该如何处理菜单操作(设置包含页面)

注:这必须是标准模式,而不包括静态内容。但我在网上找到的例子很少

菜单.xhtml

<rich:toolbar itemSeparator="line">
...
<rich:dropDownMenu mode="ajax">

    <f:facet name="label">
                <h:panelGroup>
                    <h:outputText value="Menu 1" />
                </h:panelGroup>
            </f:facet>
            <rich:menuItem id="newActivityMenu" action="#{navigationBean.menuAction}" render="content" label="New">
                <a4j:param id="newActivityParam" name="includeContentPage" value="/user/Create.xhtml" />
            </rich:menuItem>
...
...
<ui:define name="top">
        <ui:include src="/resources/viewComponents/menuTop.xhtml"/>
    </ui:define>
    <ui:define name="content">                
        <ui:include src="#{navigationBean.includedContentPage}"/>
    </ui:define>
...
layoutClient.xhtml

<rich:toolbar itemSeparator="line">
...
<rich:dropDownMenu mode="ajax">

    <f:facet name="label">
                <h:panelGroup>
                    <h:outputText value="Menu 1" />
                </h:panelGroup>
            </f:facet>
            <rich:menuItem id="newActivityMenu" action="#{navigationBean.menuAction}" render="content" label="New">
                <a4j:param id="newActivityParam" name="includeContentPage" value="/user/Create.xhtml" />
            </rich:menuItem>
...
...
<ui:define name="top">
        <ui:include src="/resources/viewComponents/menuTop.xhtml"/>
    </ui:define>
    <ui:define name="content">                
        <ui:include src="#{navigationBean.includedContentPage}"/>
    </ui:define>
...
。。。
...
主布局.xhtml(已添加)

。。。
最高违约
左默认
内容默认值
..

您还必须有一个模板页面,因为您在
layoutClient.xhtml
中定义top和content,所以我认为您试图对
layoutClient.xhtml
页面过于笼统,因为它似乎也起到了模板的作用。假设您的模板页面名为
template.xhtml
。您避免使用的标准模式是使模板页面如下所示:

template.xhtml page2.xhtml

...
这是另一个定义某些内容的页面,还包括从template.xhtml继承的“我的菜单”

...
这两个页面都继承您的菜单,并将内容放在适当的位置


使用这种配置,
menuAction()
方法需要做的就是返回一个指向
page1.xhtml
page2.xhtml
的链接。此外,您不需要复杂地使用参数或手动调用
renderResponse()
a4j:param
标记

实际上,ui:include标记是页面上其他ajax操作(而不是菜单操作)的调用,在这里我没有显式地呈现“content”div。感谢您的重播。我确实有一个名为masterLayout.xhtml(如上)的模板文件,但忘了包含它。也许我会努力将内容动态加载到同一页面中。但是有了你的解决方案,我猜整个页面都必须刷新?是的,没错。为更干净、更易于维护的代码(IMO)付出的代价很小。此外,如果您在页面中始终使用AJAX,则“后退”按钮将按预期工作。如果使用AJAX进行导航,它将不会记录在页面历史记录中,因此按back键将使用户转到
layoutClient.xhtml
之前的最后一个页面。
...
<ui:insert name="top">
    <ui:include src="/resources/viewComponents/menuTop.xhtml"/>
</ui:insert>
...
<ui:insert name="content" />
...
<ui:composition template="template.xhtml">
    ...
    <ui:define name="content">
        <p>This is a page that defines some content and also includes my menu that it inherits from template.xhtml</p>
    </ui:define>
    ...
</ui:composition>
<ui:composition template="template.xhtml">
    ...
    <ui:define name="content">
        <p>This is another page that defines some content and also includes my menu that it inherits from template.xhtml</p>
    </ui:define>
    ...
</ui:composition>