A4JSF only works once on the site...
michi_h Aug 30, 2007 6:06 AMHello,
First at all: I use Richfaces 3.1.0 RC3
I've used quite a lot a4j features in my site, and I never had any major problems. But now I have a problem that I can't solve and I don't know if it's an a4j-bug or if it's a problem from my side...
The problem is, that I have a simple site, with an h:selectOneMenu. The first problem was the a4j:support (for the selectOneMenu) didn't always sent the data on the "onchange" event. I solved this by using a4j:jsFunction (and removing a4j:support)...
The user can select something in this menu, and after he selected an item, a part of the site is reloaded with a4j (I use jsp:include to include other parts when the user selects an item). And there's the problem. I have some a4j stuff in my included pages (well, buttons and some input-fields). When I click an button, the method from the bean is called. But when I click another (or the same) button again, nothing happens. I've checked if the bean is still in the session-scope, but everything seems fine there. Even the post-command is the same.
Here's the code:
<f:view locale="#{LoginBean.language}"> <f:loadBundle basename="com.ios.web.properties.MessageResources" var="msg" /> <h:form> <a4j:region> <a4j:jsFunction name="armSelected" reRender="servicearmdata" ajaxSingle="true" status="genajaxloading"> <a4j:actionparam name="selectedArm" assignTo="#{processBowlModuleService.selectedTab}"></a4j:actionparam> </a4j:jsFunction> <h:selectOneMenu styleClass="inputtextclass" value="#{processBowlModuleService.selectedTab}" onchange="armSelected(this[this.selectedIndex].value);"> <f:selectItems value="#{processBowlModuleService.armItems}" /> </h:selectOneMenu> <h:panelGrid border="1" id="servicearmdata" styleClass="panelgridcontent"> <% com.ios.web.beans.ProcessBowlModuleService myBean = (com.ios.web.beans.ProcessBowlModuleService) session .getAttribute("processBowlModuleService"); String includePage = "../include/servicearms/" + myBean.getArmIncludeName() + ".inc.jsp"; %> <jsp:include page="<%= includePage %>" /> </h:panelGrid> <jsp:include page="/include/genajaxloading.inc.jsp" /> </a4j:region> </h:form> <jsp:include page="/include/errorpanel.inc.jsp" /> <a4j:outputPanel id="hiddenerrorinformation" ajaxRendered="true"> <h:inputHidden id="errorid" value="#{LoginBean.state}" /> <h:inputHidden id="errormsg" value="#{LoginBean.errorMsg}" /> </a4j:outputPanel> </f:view>
And here's the code of one of the included pages:
<f:subview id="pneumaticxpneumaticzarmview"> <a4j:region id="mainsubregion"> <h:panelGrid columns="2"> <h:panelGrid columns="4"> <h:outputText id="textp700" value="#{msg.xAxisLabel}:" /> <h:outputText id="textp701" value="#{msg.ventilLabel}:" /> <h:outputText id="textp702" value="#{pneumaticXPneumaticZArmBean.axisXValveStatus}" /> <a4j:commandButton status="genajaxloading" styleClass="buttonclass" id="leftbutton" value="#{msg.leftLabel}" action="#{pneumaticXPneumaticZArmBean.btnLeft}" disabled="#{!pneumaticXPneumaticZArmBean.pageEnabled}" ajaxSingle="true"></a4j:commandButton> <rich:spacer id="spacer48" /> <h:outputText id="textp703" value="#{msg.sensorLabel} #{msg.leftLabel}" /> <h:outputText id="textp704" value="#{pneumaticXPneumaticZArmBean.axisXLeftSensorStatus}" /> <a4j:commandButton status="genajaxloading" styleClass="buttonclass" id="rightbutton" value="#{msg.rightLabel}" action="#{pneumaticXPneumaticZArmBean.btnRight}" disabled="#{!pneumaticXPneumaticZArmBean.pageEnabled}" ajaxSingle="true"></a4j:commandButton> <rich:spacer id="spacer49" /> <h:outputText id="textp705" value="#{msg.sensorLabel} #{msg.rightLabel}" /> <h:outputText id="textp706" value="#{pneumaticXPneumaticZArmBean.axisXRightSensorStatus}" /> <rich:spacer id="spacer50" /> <h:outputText id="textp707" value="#{msg.zAxisLabel}" /> <h:outputText id="textp708" value="#{msg.ventilLabel}" /> <h:outputText id="textp709" value="#{pneumaticXPneumaticZArmBean.axisZValveStatus}" /> <a4j:commandButton status="genajaxloading" styleClass="buttonclass" id="upbtn" value="#{msg.upLabel}" action="#{pneumaticXPneumaticZArmBean.btnUp}" disabled="#{!pneumaticXPneumaticZArmBean.pageEnabled}" ajaxSingle="true"></a4j:commandButton> <rich:spacer id="spacer51" /> <h:outputText id="textp710" value="#{msg.sensorUpLabel}" /> <h:outputText id="textp711" value="#{pneumaticXPneumaticZArmBean.axisZSensorUpStatus}" /> <a4j:commandButton status="genajaxloading" styleClass="buttonclass" id="downbtn" value="#{msg.downLabel}" action="#{pneumaticXPneumaticZArmBean.btnDown}" disabled="#{!pneumaticXPneumaticZArmBean.pageEnabled}" ajaxSingle="true"></a4j:commandButton> <rich:spacer id="spacer52" /> <h:outputText id="textp712" value="#{msg.sensorDownLabel}" /> <h:outputText id="textp713" value="#{pneumaticXPneumaticZArmBean.axisZSensorDownStatus}" /> </h:panelGrid> <h:panelGrid columns="2"> <a4j:commandButton status="genajaxloading" styleClass="buttonclass" id="homebtn" value="#{msg.homeLabel}" action="#{pneumaticXPneumaticZArmBean.btnHome}" reRender="pneumaticxpneumaticzarmgrid" disabled="#{!pneumaticXPneumaticZArmBean.pageEnabled}" ajaxSingle="true"></a4j:commandButton> <a4j:commandButton status="genajaxloading" styleClass="buttonclass" id="parkbtn" value="#{msg.parkpositionLabel}" action="#{pneumaticXPneumaticZArmBean.btnPark}" reRender="pneumaticxpneumaticzarmgrid" disabled="#{!pneumaticXPneumaticZArmBean.pageEnabled}" ajaxSingle="true"></a4j:commandButton> </h:panelGrid> </h:panelGrid> <jsp:include page="/include/genajaxloading.inc.jsp" /> </a4j:region> </f:subview>