好的,我这里有问题。我有一个 baseTemplate.xhtml:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<!-- Incluir Scripts e Folhas de Estilo comuns a todas as páginas do sistema -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h:outputStylesheet library="css" name="default.css"/>
<h:outputStylesheet library="css" name="cssLayout.css"/>
<h:outputStylesheet library="css" name="rodape.css"/>
<title>SisEventos - Sistema de Gerenciamento de Eventos</title>
</h:head>
<h:body>
<div class="estrutura">
<div class="top">
</div>
<div class="menu">
<!-- <ui:insert name="menu"> -->
<h:form id="frmMenu">
<p:menubar autoDisplay="true" >
<p:menuitem value="Home" icon="ui-icon-home" url="/paginas/home.xhtml" />
<p:submenu label="Manutenção" icon="ui-icon-person">
...
</p:submenu>
<p:submenu label="Atividades" >
...
</p:submenu>
<p:submenu label="Relatórios" >
...
</p:submenu>
<p:submenu label="Evento" >
...
</p:submenu>
<p:menuitem value="Contato" />
</p:menubar>
</h:form>
</div>
<div class="left_content">
<ui:insert name="content">
</ui:insert>
</div>
<div class="bottom">
...
</div>
</div>
</h:body>
和这样的客户页面:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
template="./../../resources/templates/baseTemplate.xhtml">
<ui:define name="content">
<!-- Configuração do idioma de exibição do scheduler -->
<h:outputScript library="scripts" name="primefaces-locale.js"/>
<p:fieldset legend="Gerenciar eventos">
<h:form id="frmEventos">
<!-- Exibição de mensagens gerais -->
<p:growl id="gMessages" sticky="false" globalOnly="true" />
<p:schedule id="schedEventos"
value="#{eventoBeanTeste.listaEventos}"
widgetVar="schEventos" locale="pt">
<p:ajax event="eventSelect"
listener="#{eventoBeanTeste.onEventSelect}"
update="frmEventos"
oncomplete="dlgNovo.show();"/>
<p:ajax event="dateSelect"
listener="#{eventoBeanTeste.onDateSelect}"
update="frmEventos"
oncomplete="dlgNovo.show();"/>
</p:schedule>
<p:dialog id="dlgNovoEvento"
widgetVar="dlgNovo"
modal="true"
header="Novo evento"
resizable="false"
draggable="true">
<p:panelGrid id="pgNovoEvento" columns="1" styleClass="gridNoLine">
<p:row>
<p:messages id="mNovoMessages" redisplay="false"/>
</p:row>
...
<p:row>
<p:commandButton value="Cancelar"
immediate="true"
onclick="dlgNovo.hide();"/>
<p:commandButton id="cbNovoSalvar"
value="Salvar"
actionListener="#{eventoBeanTeste.cadastrarEvento}"
oncomplete="schEventos.update(); handleAction(xhr, status, args);"
update="@form frmEventos:gMessages"/>
</p:row>
</p:panelGrid>
</p:dialog>
</h:form>
</p:fieldset>
<script type="text/javascript">
function handleAction(xhr, status, args){
if(args.close){
dlgNovo.hide();
}
}
</script>
</ui:define>
bean中的一个动作如下:
@ManagedBean(name = "eventoBeanTeste")
@SessionScoped
public class EventoBeanTeste {
...
// Listener de cadastro de evento
public void cadastrarEvento(ActionEvent e) {
MessageHelper.showGlobalMessage("Fired!", FacesMessage.SEVERITY_INFO);
}
...
}
我的问题是:没有调用 cadastrarEvento 动作监听器!似乎命令按钮不起作用!可能有什么问题?