Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/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
Jsf 2 行动不是';t在第一次单击时调用_Jsf 2_Primefaces - Fatal编程技术网

Jsf 2 行动不是';t在第一次单击时调用

Jsf 2 行动不是';t在第一次单击时调用,jsf-2,primefaces,Jsf 2,Primefaces,我有一个带有身份验证的页面,该页面用于我的模板页面,其中有菜单 <navigation-rule> <from-view-id>pages/login.xhtml</from-view-id> <navigation-case> <from-outcome>userOK</from-outcome> <to-view-id>pages/template.xhtml<

我有一个带有身份验证的页面,该页面用于我的模板页面,其中有菜单

  <navigation-rule>
    <from-view-id>pages/login.xhtml</from-view-id>
    <navigation-case>
      <from-outcome>userOK</from-outcome>
      <to-view-id>pages/template.xhtml</to-view-id>
    </navigation-case>
    <navigation-case>
      <from-outcome>userNOK</from-outcome>
      <to-view-id>pages/login.xhtml</to-view-id>
    </navigation-case>    
  </navigation-rule>

pages/login.xhtml
用户OK
pages/template.xhtml
用户号
pages/login.xhtml
my page template.xhtml

<h:form>
<p:menu type="plain" style="width:200;box-shadow: 6px 6px 6px black;top:-18;left:-40" >
    <p:submenu label="Dossier" id ="Dossier" >  
        <p:menuitem update=":contentform,:messages" value="Nouveau Dossier" action="#{choix.setPage('ajoutDossier')}" 
    ....
    ....
</h:form>

<h:form id="contentform" >
    <h:panelGroup  rendered="#{choix.page == 'ajoutDossier'}">
        <ui:include src="Dossier/ajoutDossier.xhtml" />
    </h:panelGroup>
    ....
    ....
</h:form>


我发现我必须在有问题的页面的
之后添加
的解决方案,因为我了解到JSF使用内部转发而不是重定向来导航到成功页面,这就是为什么URL不会更改,但我真的不明白为什么

以下是工作人员的代码:

  <navigation-rule>
    <from-view-id>pages/login.xhtml</from-view-id>
    <navigation-case>
      <from-outcome>userOK</from-outcome>
      <to-view-id>pages/template.xhtml</to-view-id>
      <redirect />
    </navigation-case>
    <navigation-case>
      <from-outcome>userNOK</from-outcome>
      <to-view-id>pages/login.xhtml</to-view-id>
    </navigation-case>    
  </navigation-rule>

pages/login.xhtml
用户OK
pages/template.xhtml
用户号
pages/login.xhtml
为了不丢失重定向页面的css,我必须添加这个

<link rel="stylesheet" href="#{request.contextPath}/css/style.css" />

您没有利用JSF模板。不要使用一个模板和多个模板客户端,而是将所有内容都放在一个页面中;并有条件地呈现内容。查看本教程或任何其他关于jsf tempaltes的教程。
通常你会有一个模板,它有所有页面共有的布局和内容;并根据需要多次使用标签
默认内容
(使用不同的名称)。然后创建一个模板客户端,使用

<ui:composition template="./../resources/templates/templateFile.xhtml">

然后使用标记
设置要包含在模板中的内容

除此之外,关于代码中导航的问题:当您进行导航时,您不会更新内容,因为在导航之后,页面将完全加载(没有ajax)。所以首先你必须删除你的更新属性;还必须将p:menuitem的“ajax”属性设置为false;因为默认情况下这是真的。否则将无法进行导航。

如果操作正常,则导航规则中的重定向属性不是必需的。它可以与前锋完美配合。forward的唯一问题是浏览器URL不会更改,因为浏览器不会收到导航通知。

我认为您误解了jsf中模板的概念。。模板只是一个模板,您永远不会导航到模板。。在模板中,指定希望模板客户端使用标记插入内容的位置。然后,创建一个模板客户端(一个使用该模板并声明插入内容的xhtml页面)。导航到模板客户端。模板是什么意思?对于我来说,模板是一个布局为西、北或中的页面,然后我使用
,并使用呈现的属性将页面放置在某个布局(中)
我可以给出一个最佳解决方案吗?你应该使用
进行CSS。