Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.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
SpringWebFlow和JSF模板_Jsf_Spring Webflow - Fatal编程技术网

SpringWebFlow和JSF模板

SpringWebFlow和JSF模板,jsf,spring-webflow,Jsf,Spring Webflow,我想创建由“标题”和“内容”组成的页面。我创建common.xhtml <ui:insert name="header"> <ui:include src="commonHeader.xhtml" /> </ui:insert> <ui:insert name="content"> <ui:include src="commonContent.xhtml" /> </ui:insert> 然后我创建了两

我想创建由“标题”和“内容”组成的页面。我创建common.xhtml

<ui:insert name="header">
    <ui:include src="commonHeader.xhtml" />
</ui:insert>
<ui:insert name="content">
    <ui:include src="commonContent.xhtml" />
</ui:insert>

然后我创建了两个页面(create_user_page.xhtml和search_page.xhtml),它们必须具有相同的“标题”,但“内容”不同


用于创建的内容。。。


内容搜索。。。
在我的web_flow.xml中

<view-state id="start_page" view="administrator/main_page.xhtml">
    <transition on="create_user" to="create_user_page" />
    <transition on="find_user" to="search_page" />
    <transition on="back" to="back" />
</view-state>

<view-state id="create_user_page" view="administrator/create_user_page.xhtml">
    <transition on="create_user" to="create_user_page" />
    <transition on="find_user" to="search_page" />
</view-state>

<view-state id="search_page" view="administrator/search_page.xhtml">
    <transition on="create_user" to="create_user_page" />
    <transition on="find_user" to="search_page" />
</view-state>

在main_page.xhtml中,我有两个操作“create_user”和“find_user”(在“header”中),这两个操作会导致页面 创建_user_page.xhtml和搜索_page.xhtml。它们有相似的“标题”和不同的“内容”。所有这些都很好,但我有一些问题

1) 似乎每次我进入create_user_page.xhtml或search_page.xhtml时,“header”都会被重新呈现,还是我错了?“标题”是否可能保留而不重新呈现,并且仅对“内容”进行更改

2) 在我的web流xml中,我必须复制代码

<transition on="create_user" to="create_user_page" />
<transition on="find_user" to="search_page" />


用于“创建用户页面”和“搜索页面”。请记住这些操作发生在“页眉”中,这两个页面是相同的。JSF模板将始终重新呈现页眉/页脚。就个人而言,我不认为这是一个问题,除非你有一些真正的性能密集型在那里。可以通过以下方法避免重新渲染:

  • 使用HTML框架
  • 部分渲染-在SWF流中(请参见中的标记),或类似PrimeFaces的部分渲染
  • 如果使用这两种方法中的任何一种,您都可能需要重新设计XHTML和流——实际上,您的部分呈现将替换流定义。比如:

     <h:commandLink value="go to search page" actionListener="#{myBean.goToSearchPage}" update="content"></h:commandLink>
     <h:commandLink value="go to another page" actionListener="#{myBean.goToAnotherPage}" update="content"></h:commandLink>
    
    <h:panelGroup id="content">
     <h:panelGroup id="search-page" rendered="#{myBean.isThisSearchPage}">
       <!-- search page contents here -->
     </h:panelGroup>
     <h:panelGroup id="another-page" rendered="#{myBean.isThisAnotherPage}">
       <!-- another page contents here -->
     </h:panelGroup>
    </h:panelGroup>
    
    
    
    上述方法显然不易维护,不推荐使用。改用标准SWF,并在视图更改时重新渲染页眉/页脚。您仍然可以在SWF视图中使用部分呈现来响应用户的输入,而无需重新呈现整个页面


    关于第二个问题:您可以使用全局转换和流继承。请参见

    谢谢@rootkit007的回答。一个小小的澄清:对于“内容”,我有不同的页面。所以我想显示另一个页面,而不是重新呈现同一个页面。据我所知,如果您想重新呈现相同的页面,或者我错了,“部分呈现”是合适的?我添加了XHTML示例。部分呈现适用于在不刷新其他所有内容的情况下重新呈现当前页面的部分,这是正确的
    <transition on="create_user" to="create_user_page" />
    <transition on="find_user" to="search_page" />
    
     <h:commandLink value="go to search page" actionListener="#{myBean.goToSearchPage}" update="content"></h:commandLink>
     <h:commandLink value="go to another page" actionListener="#{myBean.goToAnotherPage}" update="content"></h:commandLink>
    
    <h:panelGroup id="content">
     <h:panelGroup id="search-page" rendered="#{myBean.isThisSearchPage}">
       <!-- search page contents here -->
     </h:panelGroup>
     <h:panelGroup id="another-page" rendered="#{myBean.isThisAnotherPage}">
       <!-- another page contents here -->
     </h:panelGroup>
    </h:panelGroup>