2 Replies Latest reply on Apr 30, 2008 9:31 AM by yannick bardon

    prolblem with actionListener

    yannick bardon Newbie

           
      Hi,


      Here is my problem, on a page P1, I have a button that will open another page P2 and update the name of the button which is on the page P2
      AND the button on the page P2 must make visible a popup when clicked.


      My problem is, when my page P2 opens the name of the button is correct, against when I click on the button to make visible the popup, the name takes its initial value.





      Part code page P2:



      <ice:commandButton value="#{gestionDocument.nomBoutonCreerDocument}" style="width:90px;" actionListener="#{gestionTypeTag.openPopup}"></ice:commandButton>




      gestionDocument class:


      @Stateless
      @Name("gestionDocument")
      public class GestionDocumentBean implements GestionDocument{
           
           // Variables d'instance
              // Variable pour le changer le nom du bouton soit creer soit modifier
           private String nomBoutonCreerDocument;
       
             // les getters et les setters
                 ...





      code action by the button on the page P2:



      public void openPopup(){
          this.getNomBoutonCreerDocument("Ajouter")
      }




      In summary, because I do not know it is very clear: When I click the button on the page P1 : opening of the P2 page with the name of the button on the page P2 is Insert and when I click Add the button : opening of the popup but the name of the button turns the string empty.


      Could you tell me why?



      I work with the seam 2.0.1.GA framework, the application server JBoss-4.2.0.GA and eclipse 3.3


      Thank you

        • 1. Re: prolblem with actionListener
          Andy Gibson Novice

          I think what you are saying is that when you go to page 2, the button caption is fine, but when you click the button or open the popup, the button caption goes blank?


          It appears that your button caption is being set from a stateless bean. When page2 is re-rendered, the stateless bean appears to have lost the value it had originally, probably because it is stateless.


          It seems you need to keep the name of the button in a longer running scope, rather than returning it from a stateless bean.


          One way you can do it is to outject the value with a longer scope :


          i.e.


          @Stateless
          @Name("gestionDocument")
          public class GestionDocumentBean implements GestionDocument{
               
               // Variables d'instance
                  // Variable pour le changer le 
                  // nom du bouton soit creer soit modifier
                  @Out("buttonName",scope=ScopeType.Conversation)
               private String nomBoutonCreerDocument;
           
                 // les getters et les setters
                     ...
          



          Then in your page, you can simple refer to


          <ice:commandButton value="#{buttonName}" 
            style="width:90px;" 
            actionListener="#{gestionTypeTag.openPopup}">
          </ice:commandButton>
          



          The context variable, once it has been outjected from your stateless session bean, will be re-used on each page rendering depending on the scope used.


          Cheers,


          Andy Gibson

          • 2. Re: prolblem with actionListener
            yannick bardon Newbie

            Hi,


            thank you for your answers, in fact that I @Stateless to each query there is a new instantiation of my variable. Suddenly, I created a class without @Stateless but with @Scope(ScopeType.SESSION), and first seen, it works


            thank you