14 Replies Latest reply on Feb 24, 2009 9:52 AM by Ruediger xxx

    dataScroller actionListener before "apply_request_phase"?

    Ruediger xxx Newbie

      Hi,

      i have the following requirement:
      a rich:datatable with one row is used to display the current master-element (of a list of master elements), below the detail-element is displayed.
      a rich-datascroller can be used to scroll through the master-elements.

      the detail element can be edited. after clicking the datascroller (e.g. next element), the next master element should be shown in the table and the according child element should be displayed below via ajax.
      until here i was able to do it.

      my problem is, if the user changes the detail record and then navigates to the next master element, he should be asked if he wants to save his changes and be able to do so. when i use the scrollerListener or the action/actionlistener attribute of the datascroller, my code happens before the apply_request_values phase apparently, the changes from the form are not yet applied to the bound objects.

      how can i achieve this?

      thanks for your help!

        • 1. Re: dataScroller actionListener before
          Nick Belaevski Master

          Hello,

          Do you have immediate="true" for rich:datascroller?

          • 2. Re: dataScroller actionListener before
            Ruediger xxx Newbie

            no i dont.

            this would skip the validation phase right? i want to have the form validated correctly, like when i press the save (=submit) button.

            i tried it with immediate=true just to check, that doesnt work either (the backing bean object is not updated with the form value when the action method is called).

            • 3. Re: dataScroller actionListener before
              Nick Belaevski Master

              Ok, can you please add PhaseTracker to check if your code really executes before APPLY_REQUEST_VALUES phase?

              • 4. Re: dataScroller actionListener before
                Ruediger xxx Newbie

                my log file looks like this ( i also printed out the value of the bound object, it always has the old unchanged value)


                [beforePhase] RESTORE_VIEW 1
                Under ExceptionHandlerControl class BbMyBean$$EnhancerByCGLIB$$9e3aa992.setDataScroller
                Under ExceptionHandlerControl class BbMyBean$$EnhancerByCGLIB$$9e3aa992.setUi_nationalinvoicename
                [afterPhase] RESTORE_VIEW 1
                [beforePhase] APPLY_REQUEST_VALUES 2
                ... action handler... value: "oldvalue"
                ... scroller listener .... value: "oldvalue"
                [afterPhase] APPLY_REQUEST_VALUES 2


                what does that tell me?
                nationalinvoicename is the property i changed. ( there is something in the restore view phase)


                • 5. Re: dataScroller actionListener before
                  Nick Belaevski Master

                  Yes, now I'm sure that it's firing on the 2nd phase. What is RF version?

                  • 6. Re: dataScroller actionListener before
                    Ruediger xxx Newbie

                    richfaces-impl-3.3.0.GA
                    jsf-impl-1.2_09

                    • 7. Re: dataScroller actionListener before
                      Nick Belaevski Master

                      I've just checked datascroller in 3.3.0.GA:

                      <h:form>
                       <rich:dataTable id="dtrChfImediataList" var="item"
                       value="#{forum5Bean.lotOfData}" rows="10">
                       <rich:column>
                       <f:facet name="header">
                       <rich:datascroller actionListener="#{forum5Bean.listener}"/>
                       </f:facet>
                      
                       #{item}
                       </rich:column>
                      
                       </rich:dataTable>
                       </h:form>

                      Listener fires on INVOKE_APPLICATION phase as it should be. Can you please post page code?

                      • 8. Re: dataScroller actionListener before
                        Ruediger xxx Newbie

                        thanks for looking into this.

                        <rich:dataTable id="frm_country_sr_tbl" value="#{BbCountrySearch.searchResults}" var="elem" rows="1" rowClasses="row1, row2" rowKeyVar="row" headerClass="cu-tableheader">
                        <rich:datascroller id="tblscroller" align="center" for="frm_country_sr_tbl" maxPages="6" fastControls="show" stepControls="hide" pageIndexVar="pageIndex" pagesVar="pages" reRender="eventsPageCount, recordCount, mainpanel" scrollerListener="#{BbCountrySearch.doScroll}" binding="#{BbCountrySearch.dataScroller}" actionListener="#{BbCountrySearch.doSavex}" />
                        ...
                        </h:form>


                        • 9. Re: dataScroller actionListener before
                          Nick Belaevski Master

                          Do you redefine any data scroller attributes by binding?

                          • 10. Re: dataScroller actionListener before
                            Ruediger xxx Newbie

                            no, i only use it to set it to the correct page when i open it:

                            this.dataScroller.setPage(this.searchResults.indexOf(this.selectedCountry) + 1);


                            • 11. Re: dataScroller actionListener before
                              Nick Belaevski Master

                              Sorry, but I still cannot reproduce the issue. Here is my page code:

                              <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                               xmlns:ui="http://java.sun.com/jsf/facelets"
                               xmlns:h="http://java.sun.com/jsf/html"
                               xmlns:f="http://java.sun.com/jsf/core"
                               xmlns:a4j="http://richfaces.org/a4j"
                               xmlns:rich="http://richfaces.org/rich"
                               xmlns:c="http://java.sun.com/jstl/core"
                               xmlns:fn="http://java.sun.com/jsp/jstl/functions">
                               <html>
                               <head></head>
                              
                               <body>
                              
                               <h:form>
                              
                               <rich:datascroller id="tblscroller" align="center"
                               for="frm_country_sr_tbl" maxPages="6" fastControls="show"
                               stepControls="hide" pageIndexVar="pageIndex" pagesVar="pages"
                               reRender="eventsPageCount, recordCount, mainpanel"
                               actionListener="#{forum5Bean.printDate}" />
                              
                               <rich:dataTable id="frm_country_sr_tbl"
                               value="#{forum5Bean.lotOfData}" var="item" rows="1"
                               rowClasses="row1, row2" rowKeyVar="row" headerClass="cu-tableheader">
                               <rich:column>
                               #{item}
                               </rich:column>
                              
                               </rich:dataTable>
                              
                              
                               </h:form>
                              
                               </body>
                              
                               </html>
                              </ui:composition>


                              I guess some parent component is redefining scroller's "immediate" attribute. Can you please post full page code?

                              • 12. Re: dataScroller actionListener before
                                Ruediger xxx Newbie

                                i tried your example and it worked.
                                it seems like the problem was partly solved by cleaning the tomcat work-directory and restarting eclipse. i think the property immediate=true may have been set at some point and was still in the cache or something like that. sorry for that.

                                now the actionlistener method is invoked in the correct phase (INVOKE_APPLICATION 5), but the values are still not applied to the model. i can see them in the request, but the model-object is not updated. the setter method of the property is never called.
                                the form field is bound to BbCountrySearch.selectedCountry.invoicename

                                this is not correct jsf-behaviour, is it? (sorry, im still new to jsf)

                                2009-02-24 14:17:45,169 [http-8080-9] DEBUG com.csc.cardupdate.common.CUSecurityFilter - Received Request: /administration/countryEdit.xhtml
                                2009-02-24 14:17:45,169 [http-8080-9] DEBUG com.csc.cardupdate.common.CUPhaseListener - [beforePhase] RESTORE_VIEW 1
                                2009-02-24 14:17:45,179 [http-8080-9] DEBUG com.csc.cardupdate.common.exceptions.JsfExeptionHandler - Under ExceptionHandlerControl class com.csc.cardupdate.administration.BbCountrySearch$$EnhancerByCGLIB$$ac720995.setDataScroller
                                2009-02-24 14:17:45,179 [http-8080-9] DEBUG com.csc.cardupdate.common.exceptions.JsfExeptionHandler - Under ExceptionHandlerControl class com.csc.cardupdate.administration.BbCountrySearch$$EnhancerByCGLIB$$ac720995.setUi_nationalinvoicename
                                2009-02-24 14:17:45,179 [http-8080-9] DEBUG com.csc.cardupdate.common.CUPhaseListener - [afterPhase] RESTORE_VIEW 1
                                2009-02-24 14:17:45,179 [http-8080-9] DEBUG com.csc.cardupdate.common.CUPhaseListener - [beforePhase] APPLY_REQUEST_VALUES 2
                                2009-02-24 14:17:45,189 [http-8080-9] DEBUG com.csc.cardupdate.common.exceptions.JsfExeptionHandler - Under ExceptionHandlerControl class com.csc.cardupdate.template.BbMessages$$EnhancerByCGLIB$$27a8aa0b.getMessages2
                                2009-02-24 14:17:45,189 [http-8080-9] DEBUG com.csc.cardupdate.common.exceptions.JsfExeptionHandler - Under ExceptionHandlerControl class com.csc.cardupdate.template.BbMessages$$EnhancerByCGLIB$$27a8aa0b.getFirstMessage
                                2009-02-24 14:17:45,189 [http-8080-9] DEBUG com.csc.cardupdate.common.exceptions.JsfExeptionHandler - Under ExceptionHandlerControl class com.csc.cardupdate.administration.BbCountrySearch$$EnhancerByCGLIB$$ac720995.getSearchResults
                                2009-02-24 14:17:45,189 [http-8080-9] DEBUG com.csc.cardupdate.common.CUPhaseListener - [afterPhase] APPLY_REQUEST_VALUES 2
                                2009-02-24 14:17:45,189 [http-8080-9] DEBUG com.csc.cardupdate.common.CUPhaseListener - [beforePhase] PROCESS_VALIDATIONS 3
                                2009-02-24 14:17:45,189 [http-8080-9] DEBUG com.csc.cardupdate.common.CUPhaseListener - [afterPhase] PROCESS_VALIDATIONS 3
                                2009-02-24 14:17:45,189 [http-8080-9] DEBUG com.csc.cardupdate.common.CUPhaseListener - [beforePhase] UPDATE_MODEL_VALUES 4
                                2009-02-24 14:17:45,189 [http-8080-9] DEBUG com.csc.cardupdate.common.CUPhaseListener - [afterPhase] UPDATE_MODEL_VALUES 4
                                2009-02-24 14:17:45,189 [http-8080-9] DEBUG com.csc.cardupdate.common.CUPhaseListener - [beforePhase] INVOKE_APPLICATION 5
                                2009-02-24 14:17:45,189 [http-8080-9] DEBUG com.csc.cardupdate.common.exceptions.JsfExeptionHandler - Under ExceptionHandlerControl class com.csc.cardupdate.administration.BbCountrySearch$$EnhancerByCGLIB$$ac720995.doSavex
                                2009-02-24 14:17:45,189 [http-8080-9] DEBUG com.csc.cardupdate.administration.BbCountrySearch - [doSavex] start (action=doSavex)
                                2009-02-24 14:17:45,189 [http-8080-9] DEBUG com.csc.cardupdate.administration.BbCountrySearch - [doSaveX] this.selectedCountry.getInvoicename(): +++ old value +++
                                2009-02-24 14:17:45,189 [http-8080-9] DEBUG com.csc.cardupdate.administration.BbCountrySearch - [doSave] start
                                2009-02-24 14:17:45,189 [http-8080-9] DEBUG com.csc.cardupdate.administration.BbCountrySearch - [doSave] this.selectedCountry.getInvoicename(): +++ old value +++
                                2009-02-24 14:17:45,249 [http-8080-9] INFO com.csc.cardupdate.common.CUNavigationHandler - [handleNavigation] action:'null' outcome:'null'
                                2009-02-24 14:17:45,249 [http-8080-9] DEBUG com.csc.cardupdate.common.exceptions.JsfExeptionHandler - Under ExceptionHandlerControl class com.csc.cardupdate.administration.BbCountrySearch$$EnhancerByCGLIB$$ac720995.doScroll
                                2009-02-24 14:17:45,249 [http-8080-9] INFO com.csc.cardupdate.common.CUPerUserPoolDataSource - [getConnection] conn.class: class com.mchange.v2.c3p0.impl.NewProxyConnection
                                2009-02-24 14:17:45,279 [http-8080-9] DEBUG com.csc.cardupdate.administration.BbCountrySearch - [doScroll] start
                                2009-02-24 14:17:45,279 [http-8080-9] DEBUG com.csc.cardupdate.administration.BbCountrySearch - [doSroll] Andorra22xxx
                                2009-02-24 14:17:45,349 [http-8080-9] DEBUG com.csc.cardupdate.common.CUPhaseListener - [afterPhase] INVOKE_APPLICATION 5
                                2009-02-24 14:17:45,349 [http-8080-9] DEBUG com.csc.cardupdate.common.CUPhaseListener - [beforePhase] RENDER_RESPONSE 6
                                2009-02-24 14:17:45,870 [http-8080-9] DEBUG com.csc.cardupdate.common.CUPhaseListener - [afterPhase] RENDER_RESPONSE 6
                                


                                • 13. Re: dataScroller actionListener before
                                  Nick Belaevski Master

                                  rich:datascroller is ajaxSingle="true" by default. Set ajaxSingle="false".

                                  • 14. Re: dataScroller actionListener before
                                    Ruediger xxx Newbie

                                    great, now it works!

                                    thanks a lot!