小编Shr*_*uti的帖子

CommandLink不在jsf表单中,因为我已将其添加到模板中.但是它被禁用.有没有其他方法来启用它?

我已经加了我commandLink(这是注销链接)到模板文件,该文件是不是一个内部的JSF表单.

MainTemplate.xhtml

<h:commandLink action="#{welcomeBean.logOutSession}" class="subAnchor" value="Log Out">
</h:commandLink>
Run Code Online (Sandbox Code Playgroud)

对使用该模板的网页,我有一个JSF表单中的所有元素:

NewWelcome.xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                 xmlns:h="http://xmlns.jcp.org/jsf/html"
                 xmlns:f="http://xmlns.jcp.org/jsf/core"
                 xmlns:ui="http://java.sun.com/jsf/facelets"
                 template="/webpages/templates/MainTemplate.xhtml">

  <ui:define name="infomationPartOfBody">
     <h:form>
<div>  Here i have all the page specific content </div>

 </h:form>
 </ui:define>

 </ui:composition>
Run Code Online (Sandbox Code Playgroud)

我希望注销将工作,一旦我在页面中使用的模板与JSF表单.然而,注销commandLink显示错误:

注销:因为它不嵌套在JSF表单中的这个链接被禁用.

我知道一个明确的解决办法是单独添加这些元素到每个将使用该模板的XHTML页面的.但我希望它被添加到模板本身,因为它是一种常见的元素中的所有页面.

任何帮助将深表感谢.谢谢!:)

编辑: 这是我的MainTemplate.xhtml的代码

 <?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://xmlns.jcp.org/jsf/html"
 xmlns:f="http://xmlns.jcp.org/jsf/core"
   xmlns:ui="http://java.sun.com/jsf/facelets">
 <f:view>

    <h:head>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/cupertino/jquery-ui.css"/>
        <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.0.js"></script>
        <script type="text/javascript" src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
    <script type="text/javascript" src="../JavaScriptPages/JQueryFile.js"></script>

        <title>State Transport Department- Work Schedule</title> 
        <link  rel="stylesheet" type="text/css" href="../CSS/CompleteTemplateCSS.css"/> …
Run Code Online (Sandbox Code Playgroud)

java xhtml templates jsf-2

6
推荐指数
1
解决办法
8971
查看次数

标签 统计

java ×1

jsf-2 ×1

templates ×1

xhtml ×1