1 Reply Latest reply on Apr 21, 2008 4:23 AM by Ilya Shaikovsky

    A4J, Selectonemenus  dependencies  and validation (r:message

    paata lominadze Master

      hello guys,
      i have two selectonemenu, first is parent and second is child, both of them must be required.
      i use jboss seam(2.0) framework with richfaces (3.4.1).
      my task is create ajax wizard (i found example about it), on first page i have two selectonemenus, which i described above.
      everything works fine except messaging for requirement.
      my code snippets :

       <h:selectOneMenu id="dbType" styleClass="LoginLangCombo" value="#{dbparams.dbVendor}">
       <s:selectItems value="#{dbVendors.resultList}" var="vendor" label="#{vendor.dbvendorname}" />
       <s:convertEntity />
       <a4j:support event="onchange" reRender="dbType,dbDriverid" bypassUpdates="false"/>
       <h:selectOneMenu id="dbDriverid" styleClass="LoginLangCombo" value="#{dbparams.dbDriver}">
       <s:selectItems value="#{dbDrivers.resultList}" var="driver" label="#{driver.dbDriverName}"/>
       <s:convertEntity />
       <f:validator validatorId="SelectValidator"/>
       <rich:message for="dbDriverid"
       passedLabel="No Error"
       title="this is tooltip">
       <f:facet name="errorMarker">
       <h:graphicImage url="/img/error.gif"/>
       <f:facet name="fatalMarker">
       <h:graphicImage url="/img/fatal.gif"/>
       <f:facet name="infoMarker">
       <h:graphicImage url="/img/info.gif"/>
       <f:facet name="warnMarker">
       <h:graphicImage url="/img/warn.gif"/>
       <f:facet name="passedMarker">
       <h:graphicImage url="/img/passed.gif"/>

      public class SelectValidator implements Validator {
       public SelectValidator() {
       public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
       DbDriver dbDriver = (DbDriver) value;
       String clientId = component.getClientId(context);
       int componentNum = componentNum(component.getId());
       System.out.println("selectedValue = " + dbDriver);
       System.out.println("clientId = " + clientId);
       System.out.println("componentNum = " + componentNum);
       if (dbDriver == null) {
       FacesMessage message = new FacesMessage();
       message.setSummary("warning SUMMARY for: " + componentNum + " input");
       message.setDetail("warning DETAIL for: " + componentNum + " input");
       context.addMessage(clientId, message);
       public int componentNum(String baseId) {
       if (baseId.endsWith("1")) {
       return 1;
       } else if (baseId.endsWith("2")) {
       return 2;
       } else if (baseId.endsWith("3")) {
       return 3;
       } else if (baseId.endsWith("4")) {
       return 4;
       return -1;

      3.components.xml for database queries
      <framework:entity-home name="dbVendorHome" entity-class="com.magticom.billing.jbossmonitor.beans.entity.jits.DbVendor"/>
       <factory name="dbVendor" value="#{dbVendorHome.instance}"/>
       <framework:entity-query name="dbVendors" ejbql="select v from DbVendor v" order="v.id"/>
       <framework:entity-home name="dbDriverHome" entity-class="com.magticom.billing.jbossmonitor.beans.entity.jits.DbDriver"/>
       <factory name="dbDriver" value="#{dbDriverHome.instance}"/>
       <framework:entity-query name="dbDrivers" ejbql="select v from DbDriver v">
       <value>v.dbVendor = #{dbparams.dbVendor}</value>

      1. validation is not working is second menu is empty.
      2.i tried to add required attribute for second menu, but after this filtering is not working.
      second menu filled every second time ignoring what i choose from first menu, every first time is empty.

      any idea will be appreciated.

      Paata Lominadze
      Magticom LTD.