0 Replies Latest reply on Mar 15, 2013 5:42 AM by mmunir

    popupPanel changes the viewstate

    mmunir

      I am using jsf 2.1 with richfaces 4.2.3. The application contains a JSF form where user can add/delete and update the books information. This form contains one rich:datatable component to show data for books in tabular form and four popupPanels to add, delete, edit and edit pictures of books.

      This web application supports two languages: English and French. When I click the french language hyperlink, it displays correctly the form in french language. However, if i open the edit row popup and click the cancel button to hide this popup and now click the french hyperlink, then rows in table changes and contains different values for its columns.

      It seems that the viewstate of table is changed. Can you please guide me as how to fix this issue.

      Following is the code for this:

      book.xhtml

      <rich:dataTable iterationStatusVar="it" columnsWidth="8%,18%,22%,12%,8%,10%,15%, 7%" rows="10" width="100%" var="record"

                                value="#{bookBean.books}" rowClasses="oddRow,evenRow" id="table">
        
      <f:facet name="noData">
             #{msg.nothing}
        
      </f:facet>

           ..............

      <a4j:commandLink styleClass="no-decor" render="editGrid" execute="@this" oncomplete="#{rich:component('editPane')}.show()">
                                         
      <h:graphicImage value="resources/images/edit.gif" alt="edit" />
                                         
      <a4j:param value="#{it.index}" assignTo="#{bookBean.currentBookIsbn}" />
                                         
      <f:setPropertyActionListener target="#{bookBean.editedBook}" value="#{record}" />
                                     
      </a4j:commandLink>

           .............

      </rich:dataTable>

      <rich:popupPanel header="#{msg.popHeader}" id="editPane" domElementAttachment="parent" autosized="true">

             .....................................

         <rich:calendar id="myPdate" value="#{bookBean.editedBook.publDate}" required="true" />
        
      <h:panelGroup />
        
      <rich:message id="myPMsg" for="myPdate" /> 

         <h:outputText value="#{msg.author}" />
         <h:inputTextarea value="#{bookBean.editedBook.authors}" id="myAuthor" required="true" />
        
      <h:panelGroup />
        
      <rich:message id="myPAuth" for="myAuthor" />
         ...................

         <a4j:commandButton value=" #{msg.cancel} " onclick="#{rich:component('editPane')}.hide(); return false;" />
                                     

      </rich:popupPanel>

      BookBean.java

      @ManagedBean
      @ViewScoped
      public class BookBean implements Serializable {

         
      private List<Book> books;
         
      private List<Edition> editions;

      ......................

      Header.xhtml

      <div class="menutext"><h:commandLink id="French" actionListener="#{language.onChooseLocale}" value="#{msg.french}"

      class="#{language.localeCode=='fr' ? 'fr' : ''}" disabled="#{language.localeCode=='fr' ? 'true' : 'false'}" />


      <div class="menutext"><h:commandLink id="English" actionListener="#{language.onChooseLocale}" value="#{msg.english}"

      class="#{language.localeCode=='en' ? 'en' : ''}"  disabled="#{language.localeCode=='en' ? 'true' : 'false'}" />
                     

      LanguageBean.java

      public void onChooseLocale(ActionEvent event) {
                     
      String current;
                      current
      = event.getComponent().getId();
                     
      if ("English".equals(current))
                          localeCode
      = Locale.ENGLISH;
                     
      else
                          localeCode
      = Locale.FRENCH;

             
      }