好的,我已阅读有关此问题的所有帖子,但找不到。我的情况非常简单——我所做的只是使用 Primefaces 3.3.1 和 JSF 2.1 来呈现登录页面。这是代码:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>ACME Systems - Home Page</title>
<style>
.noBorders tr, .noBorders td {
background: none !important;
border: none !important;
}
</style>
</h:head>
<h:body>
<p:panel id="mainPanel"
style="height: 106px; height: auto !important; margin: 0 auto; min-height: 106px; position: relative; width: 960px; z-index: 100;">
<h:form id="loginForm">
<p:panel header="Secure Login"
style="padding-bottom: 40px; width: 380px;">
<p:panelGrid columns="2" styleClass="noBorders">
<h:outputText value="Username:" />
<p:inputText id="username" required="true"
requiredMessage="Username is required." title="Username"
value="#{LoginBean.username}" />
<h:outputText value="Password:" />
<p:password id="password" required="true"
requiredMessage="Password is required"
value="#{LoginBean.password}" />
</p:panelGrid>
<p:commandButton id="loginButton" value="Login"
actionListener="#{LoginBean.login}"
style="margin-top: 5px; float: right;" />
</p:panel>
</h:form>
</p:panel>
</h:body>
</html>
命令按钮上的动作侦听器未触发。如果我将其更改为 ah:commandbutton 一切都很好。我宁愿只使用 primefaces 标签,因为它使用主题。如果我使用 h: 那么我需要获取 css。有任何想法吗?另一件事,如果我将 ah:commandbutton 放在 primefaces 按钮之前,并使用它来执行初始触发,则 primefaces 按钮从那时起就可以工作:P 去图!