
[英]JSF2 preRenderComponent is called always when f:ajax is executed
[英]Jsf2 listener not called with f:ajax
我正在使用jsf2和richfaces 4。
这是我的home.xhtml
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<h:head>
<title>My Web Application</title>
<link rel="stylesheet" href="resources/stylesheet/style.css" />
</h:head>
<h:body>
<h:panelGrid columns="2">
<h:form>
<rich:panel>
<f:facet name="header">
Statut
<div class="status_refresh" style="float:right;">
<h:graphicImage styleClass="loading" value="resources/stylesheet/images/refresh.png">
<f:ajax execute="@form" event="click" listener="#{statusBean.refresh}" render="station_status station_action"/>
</h:graphicImage>
</div>
</f:facet>
<h:panelGroup id="station_status" style="display:inline-block;" class="#{statusBean.stationTableStatus?'status_ok':'status_not_ok'}">
<a4j:outputPanel>
<rich:tooltip rendered="#{statusBean.stationTableStatus != true}">
<h:outputText value="#{statusBean.stationTableStatusMessage}" />
</rich:tooltip>
<h:outputText value="Table " />
<b><h:outputText style="margin-right:10px;" value="Station" /></b>
</a4j:outputPanel>
</h:panelGroup>
<h:panelGroup id="station_action" rendered="#{statusBean.stationTableStatus != true}">
<a4j:status>
<f:facet name="start">
<div class="loading_container">
<h:graphicImage styleClass="loading" value="resources/stylesheet/images/waiting.gif" alt="Please wait ..." />
</div>
</f:facet>
<f:facet name="stop">
<h:commandButton type="button" value="Créer la table">
<a4j:ajax execute="@form" listener="#{statusBean.createStationTable}" render="station_status,station_action"/>
</h:commandButton>
</f:facet>
</a4j:status>
</h:panelGroup>
</rich:panel>
</h:form>
</h:panelGrid>
</h:body>
</html>
通过支持bean,我有:
public void createStationTable()
{
....
}
和
public void refresh()
{
System.out.println("******* start refresh() ************");
}
而且我不明白为什么调用了我的按钮的侦听器,而不是我的图像之一。
我也尝试过
public void refresh(ActionEvent actionEvent)
和
public void refresh(AjaxBehaviorEvent e)
但没有一个工作。
我还尝试了f:ajax和a4j:ajax。 相同的结果。
好吧,我尝试了您的代码,它调用了<f:ajax>
标记中定义的侦听器。
我不知道您在复制时是否错过了它,您是否丢失了</html>
。
对于<h:panelGrid>
您使用了错误的属性。 应该是styleClass
而不是class
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.