a4j:support strange events
ector7280 May 16, 2007 2:05 PMI'm using a selectOneRadio to modify a selectOneMenu and it almost works correctly except for some inconsistent behavior.
I'm passing a paramter in the querystring and sometimes
when I click the radio button the value will remain the same as the passed in value. For instance if I pass in a '3' when I click on the radio button whose value is '1', I'll get '3'. If I click again, then it turns to '1'. It seems like it's storing the initial value along with it's real value.
Also, if some unrelated fields are empty the radio button value will not change when clicked. When I enter text in that unrelated field the value will change.
Are these bugs or am I doing something wrong?
Here's the facelets page:
<f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:tr="http://myfaces.apache.org/trinidad" xmlns:rich="http://richfaces.ajax4jsf.org/rich" xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"> <html> <body> <h:messages globalOnly="true" styleClass="message" id="globalMessages" /> <h:form id="vessel" styleClass="edit"> <rich:panel> <f:facet name="header">Vessel Details</f:facet> <s:decorate id="vesselIdDecoration"> <h:inputHidden id="vesselId" disabled="#{vesselHome.managed}" value="#{vesselHome.instance.vesselId}"> <a4j:support event="onblur" reRender="vesselIdDecoration" /> </h:inputHidden> </s:decorate> <h:outputText> <fieldset title="shipyard"><legend>Shipyard</legend> <a4j:outputPanel ajaxRendered="true"> <h:panelGrid title="Shipyard Info"> <h:outputLabel for="statusDecoration"> <p align="right"><span class="required">*</span> Shipyard Status:</p> </h:outputLabel> [#{shipyardFilter.statusId}] <s:decorate id="statusDecoration"> <h:selectOneRadio id="status" value="#{shipyardFilter.statusId}" styleClass="radio"> <f:selectItem itemLabel="Open" itemValue="1" /> <f:selectItem itemLabel="Closed" itemValue="2" /> <f:selectItem itemLabel="Renamed" itemValue="3" /> <a4j:support event="onclick" reRender="shipyard" /> </h:selectOneRadio> </s:decorate> <a4j:region> <s:decorate id="shipyardDecoration"> <h:selectOneMenu id="shipyard" value="#{vesselHome.instance.shipyard}" required="true"> <s:selectItems value="#{shipyardFilter.shipyards}" var="shipyard" label="#{shipyard.name}" /> <a4j:support event="onchange" reRender="location1" /> <s:convertEntity /> </h:selectOneMenu> </s:decorate> <f:subview id="location1"> <ui:include src="VesselLocation.xhtml" /> </f:subview> </a4j:region> </h:panelGrid> </a4j:outputPanel></fieldset> </h:outputText> <h:outputText> <table> <tr> <td><h:outputLabel for="vesselName"> <p align="right"><span class="required">*</span> Name:</p> </h:outputLabel></td> <td><s:decorate id="vesselNameDecoration"> <h:inputText id="vesselName" required="true" size="50" maxlength="50" value="#{vesselHome.instance.vesselName}"> <a4j:support event="onchange" reRender="vesselNameDecoration" /> </h:inputText> </s:decorate></td> </tr> </table> </h:outputText> </rich:panel> </h:form> </body> </html> </f:view>
Here's the Seam bean:
package gov.dot.marad.business.ejb; import gov.dot.marad.persistence.ejb.model.Shipyard; import gov.dot.marad.persistence.ejb.model.VesselHome; import java.util.List; import javax.ejb.Stateless; import javax.persistence.EntityManager; import org.jboss.seam.annotations.Factory; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Out; import org.jboss.seam.annotations.datamodel.DataModel; @Stateless @Name("shipyardFilter") public class ShipyardFilterAction implements ShipyardFilter { @Out private int statusId; private List<Shipyard> shipyards; @In(create = true) EntityManager entityManager; public EntityManager getEntityManager() { return entityManager; } public int getStatusId() { return this.statusId; } public void setStatusId(int statusId) { this.statusId = statusId; } @SuppressWarnings("unchecked") @DataModel public List <Shipyard> getShipyards() { shipyards = getEntityManager().createQuery( " select shipyard from Shipyard shipyard " + " where shipyard.shipyardStatus.statusId=:status") .setParameter("status", getStatusId()).getResultList(); System.out.println("SHIPYARDFILTERACTION StatusId " + statusId); return shipyards; } }