2 Replies Latest reply on Dec 24, 2010 5:31 AM by Jason Long

    PhotoAlbum actionLister not called

    Jason Long Novice

      I have always used Richfaces in my production apps, and now I am working on a personal project.  I am working on a photo album so I started with the Richfaces Photoalbum.


      I made a few modifications, but I cannot get the actionListener to be called in one circumstance.  Below are the modifications relevant to this problem.


      I added a list of albums and and a list shelves to Model.java so that I could conditionally display more complex filtered lists.  This works fine for images and this a list is already provided in the Model.java


      I also modified the resetModel method by adding paramters for these lists.  With the modifications the photo album still functions as normal except for when I  try to use #{model.albums} inside a4j:repeat.  I am trying to pass this to the albumList.xhtml template.



          private List<Album> albums;

          public List<Album> getAlbums() { return albums; }

          public void setAlbums(List<Album> albums) {    this.albums = albums; }

          private List<Shelf> shelfs;

          public List<Shelf> getShelfs() { return shelfs; }

          public void setShelfs(List<Shelf> shelfs) { this.shelfs = shelfs; }

          public void resetModel(NavigationEnum mainArea,

                                               User selectedUser,

                                              Shelf selectedShelf,

                                              Album selectedAlbum,

                                              Image selectedImage,

                                              List<Image> images,

                                             List<Album> albums,

                                              List<Shelf> shelfs)









              this.images = images;



      I also added the following method to Controller.java




          public void selectSharedAlbums()
              model.resetModel(NavigationEnum.MODEL_ALBUMS, user, null, null, null, imageDAO.findShared(), albumDAO.findShared(), null);


      Note that I am setting the album list in the model via albumDAO.findShared().  This image list is also set imageDAO.findShared(), but this is only for my debugging example that will be shown shortly.  Normally I would set it to null;


      I stripped down the albumList.xhtml to try to find the problem, but I have had no success.  The only difference in the a4j:repeat lists show below is the value used in a4j:repeat.  Below is a stripped down version the  of albumList.xhtml template.


          <h:outputText value="List loaded from model.images" /><br/>
          <h:outputText value="The actionListener is called and shows a cast class exception as expected" /><br/>
          <a4j:repeat id="modelImages"
              <a4j:commandLink id="modelImageId"
                          reRender="mainArea, treePanel"/>
          <h:outputText value="List loaded from model.albums" /><br/>
          <h:outputText value="The actionListener is not called" /><br/>
          <a4j:repeat id="modelAlbums"
              <a4j:commandLink id="modelAlbumId"
                          reRender="mainArea, treePanel"/>
          <h:outputText value="List loaded from user.albums" /><br/>
          <h:outputText value="The actionListener is called and page is displayed properly" /><br/>
          <a4j:repeat id="userAlbums"
              <a4j:commandLink id="userAlbumId"
                          reRender="mainArea, treePanel"/>


      If I try to use a list of images a class cast exception is thrown as expected because controller.showAlbum expects an album.  If I use user.albums there no problem.  No matter what I do if I use model.albums I cannot get the actionListener to be called.  This work in this way no matter if I have only one or all three lists on the page.  The list is rendered correctly, but the actionListener is never called.


      Here are a list of my ideas for the cause of the problem:

      1.  Difference in the way that the albums are loaded.

      I use imageDAO.findShared()


          public List<Album> findShared()
              return entityManager.createQuery("from Album a where a.shared=true")


      user.getAlbums() uses


          public List<Album> getAlbums()

              final List<Album> albums = new ArrayList<Album>();
              for (Shelf s : getShelves()) {
              return albums;


      2.  Invalid markup as discussed in the link below, but this is a simple case and the other lists work even when this one is on the page.



      3.  Something to do with Seam conversations that I am misuderstanding.


      Adding immediate="true" does not help.

      Adding ajaxSingle="true" calls actionListener, but the selected album is null.


      I am getting no errors logged or other debug logged info that seems useful.


      I have spent several hours on this and I would greatly appreciate any help on how to debug or solve this problem.

        • 1. Re: PhotoAlbum actionLister not called
          Jason Long Novice

          It is definitly not the way I am loading the list.  I plugged albumDAO.findShared() directly into the a4j:repeat value and all worked as expected.


          I am unclear on why I can list images out of the model, but not albums.


          <h:outputText value="List loaded from albumDAO.findShared()" /><br/>
              <h:outputText value="The actionListener is not called" /><br/>

              <a4j:repeat id="daoAlbums"
                  <a4j:commandLink id="daoAlbumId" 
                              reRender="mainArea, treePanel"/>

          • 2. Re: PhotoAlbum actionLister not called
            Jason Long Novice

            In all of the apts that I have written I use @Factory.  Following fixed the issue, but I am still unclear about why I could load model.images, but not model.albums.


            Adding a factory to the getter method and using #{modelAlbums} instead of #{model.albums} make it work for me.  This was the only modification to the code I posted previously.


            If anyone knows why I could load the lists of images, but not the albums please comment.  I would say that is has to do with not having to call the model direcly and having modelAlbums cached in conversation scope, but I am unclear on the details since model is already conversation scope.


                private List<Album> albums;
                public List<Album> getAlbums() { return this.albums; }
                public void setAlbums(List<Album> albums) {    this.albums = albums; }