2 Replies Latest reply on Mar 19, 2012 2:29 PM by Momo Merle

    <a4j:ajax> on <h:selectonemenu> not rendered web page

    Momo Merle Newbie

      Re: a4j:ajax not working with conditionally rendered h:selectOneMenu

      Hello. I got a problem with richfaces 4.2.Final on <a4j:ajax> on <h:selectonemenu>.

      my bean is onto @SessionScoped.

      The lsitener is executed but web page is note rendered.

       

       

      my web page newAnn.xhtml

       

       

       

       

       

       

       

      my web page newAnn.xhtml

                

       

      <tr:form  id="uploadForm" usesUpload="true">

      <!--             <h:graphicImage width="130" height="114" library="projet_jsf_pictures/TNTe2lSURGvirXCgW" name="Pippa-Middleton-sans-culotte-2.jpg" />-->

      <!--<h:graphicImage width="130" height="114" value="/img/nokia-lumia-900.jpg"/>-->

       

       

      <rich:calendar> hello</rich:calendar>

                          <table border="0">

                           

                              <tr>

                                  <td class="libelle"> <h:outputText value="Region:"/></td>

                                

                                  <td>

                                      <h:selectOneMenu

                                          id="Region" value="#{annonceController.regionA}" valueChangeListener="#{annonceController.regionChanged}" >

                                                              <f:selectItems value="#{annonceController.annonce.tailleItems}"/>

                                                 <a4j:ajax event="valueChange" render="valeur" execute="@this"/>

                                       </h:selectOneMenu>

                                      <br/>

                                  </td>

                                

                                

                              </tr>

                            

                              <tr>

                                  <a4j:outputPanel id="valeur">

                                      <td class="libelle">

                                          <h:outputText  value="Departement:"  rendered="#{not empty annonceController.regionA}" />

                                      </td>

                                  </a4j:outputPanel>

                                      <td>

                                      

                                          <h:selectOneMenu value="#{annonceController.choosedDepartment}" valueChangeListener="#{annonceController.departementChanged}"                                               rendered="#{annonceController.afficher_departement}" id="department">

                                            

                                                           <f:selectItems value="#{annonceController.dept}"/>

                                          </h:selectOneMenu>

                               

                                      </td>

                                    

                                    

                                

                              </tr>

                            

       

       

       

       

       

       

       

       

       

       

       

       

       

      my bean is here

       

       

      /*

      * To change this template, choose Tools | Templates

      * and open the template in the editor.

      */

      package com.mycompany.biblio.controller;

       

       

      import com.mycompany.biblio.business.AnnonceEJB;

      import com.mycompany.biblio.business.BookEJB;

      import com.mycompany.biblio.model.Annonce;

      import com.mycompany.biblio.model.Book;

      import com.mycompany.biblio.model.Departement;

      import com.mycompany.biblio.model.Utilisateur;

      import java.io.*;

      import java.util.logging.Level;

      import java.util.logging.Logger;

      import javax.ejb.EJB;

      import javax.faces.application.FacesMessage;

      import javax.faces.bean.ManagedBean;

      import javax.faces.bean.SessionScoped;

      import javax.faces.component.html.HtmlDataTable;

      import javax.faces.context.ExternalContext;

      import javax.faces.context.FacesContext;

      import javax.faces.event.AjaxBehaviorEvent;

      import javax.faces.event.ValueChangeEvent;

      import javax.faces.model.ListDataModel;

      import javax.faces.model.SelectItem;

      import  org.apache.myfaces.trinidad.model.UploadedFile;

      /**

      *

      * @author Mahamadi

      */

      @ManagedBean

      @SessionScoped

      public class AnnonceController {

       

       

      public void regionChanged(ValueChangeEvent e){

        

                   FacesContext context = FacesContext.getCurrentInstance();

                    

                        FacesMessage message;

                      

                        if(null != e.getNewValue()){

                          //assign new value to localeCode

                      if( (Integer.parseInt(e.getNewValue().toString()))==0){

                          afficher_departement = false;

                      }else{

                          afficher_departement = true;

                          dept=departement.getDepartements(Integer.parseInt(e.getNewValue().toString())-1);

                      annonce.setCodePostal(13009);

                      message  = new FacesMessage("l_valider -------- = "+l_valider+ "  --- "+ regionA);

                        context.addMessage("xn jbnzmxvb nvzx", message);

                      }

                    

                    }

                }

       

       

       

       

      the function regionChanged() is working but web page is not rendered. When I press F5 page is rendered.

      PLease help me.