我目前正在开发一个我想要使用bootsfaces的项目。 应用程序处于运行状态。我只是为了外表重建它。
之前,有一个richFaces navigationBar工作正常,我用bootstraps默认导航栏替换它。所以我调整了所有的导航链接和标签,但唯一不起作用的是Logout-Button。
navigation.xhtml:
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:b="http://bootsfaces.net/ui"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
>
<div class="container">
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Titel und Schalter werden für eine bessere mobile Ansicht zusammengefasst -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Navigation ein-/ausblenden</span>
<span class="icon-bar"/>
<span class="icon-bar"/>
<span class="icon-bar"/>
</button>
<a class="navbar-brand" href="home.xhtml" style="padding: 4px;">
<img alt="Home" src="T_Logo_3c_p.png" width="96" height="42"/>
</a>
</div>
<!-- Alle Navigationslinks, Formulare und anderer Inhalt werden hier zusammengefasst und können dann ein- und ausgeblendet werden -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Vehicles<span class="caret"/></a>
<ul class="dropdown-menu">
<li><a href="car-overview.xhtml">Overview</a></li>
<li><a href="booking.xhtml">Booking</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">#{loginBean.username}<span class="caret"/></a>
<ul class="dropdown-menu">
<li><a href="myInfo.xhtml">My Info</a></li>
<li><a href="myOrders.xhtml">My Orders</a></li>
<li><a href="invoice.xhtml">My Invoices</a></li>
</ul>
</li>
<li class="active"><a href="report.xhtml">Submission</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Administration<span class="caret"/></a>
<ul class="dropdown-menu">
<li><a href="vehicles.xhtml">Manage Vehicles</a></li>
<li><a href="charges.xhtml">Manage Charges</a></li>
<li><a href="areas.xhtml">Manage Parking Areas</a></li>
<li><a href="damages.xhtml">Manage Damages</a></li>
<li role="separator" class="divider"/>
<li><a href="users.xhtml">Manage Users</a></li>
</ul>
</li>
<li>
<b:commandButton class="btn btn-default btn-sm" value="Log out" action="#{loginBean.logout}"/>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js" type=""/>
<script src="bootstrap/js/bootstrap.min.js" type=""/>
Home.xhtml:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:b="http://bootsfaces.net/ui"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
>
<h:head>
<meta charset="utf-8" content=""/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="shortcut icon" type="image/x-icon" href="T_favicon_p.ico"/>
<link rel="stylesheet" href="bootstrap/css/bootstrap.css"/>
<title>Azubiprojekt CarSharing</title>
</h:head>
<h:body>
<h1 class="text-center">CarSharing</h1>
<!-- include navBar here -->
<ui:include src="./navigation.xhtml" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js" type=""/>
<script src="bootstrap/js/bootstrap.min.js" type=""/>
</h:body>
</html>
SessionScoped LoginBeans方法:
public String logout() {
HttpSession session = SessionUtils.getSession();
session.invalidate();
return "index";
}
进入页面时出错:The class 'de.carsharing.beans.LoginBean' does not have the property 'logout'.
如果我将其设为action="#{loginBean.logout()}"
,则会加载页面,但点击按钮时不会调用该方法。
我已经阅读了ui:components
内部commandButtons的一些问题,所以我试图手动包含它,但它没有帮助。将它放在一个看不见的h:form中也一样。
我不知道,可能是,b:commandButtons&#34; action&#34;属性不是作为MethodExpression计算,而是作为ValueExpression计算?