0

I need to implement conditional navigation logic using rich:dataScroller. Basically based on certain rule, the page navigation for the dataTable associated with the dataScroller should not take place. As per my preliminary analysis dataScroller provides two events which can used for this purpose. One is the onbegin event and the second is scrollListener.

First I tried by using onbegin. In my first attempt I tried the following:

onbegin="return confirm('Whats up?');"

This makes no difference to the page navigation. Second option I tried was as follows:

onbegin="var v = confirm('Whats up?'); if (!v) {var curPage = Richfaces.$(this).currentPage; Richfaces.$(this).switchToPage(curPage);}"

This prevents page navigation, but leaves the scroller in an inconsistent state, no further operations can be done on the scroller.

I checked the following link, but am not sure how scrollListener can be used to prevent page navigation.

Any pointer will be appreciated.

Community
  • 1
  • 1
Vinay R
  • 1
  • 1
  • 1
  • You can put you logic at least on 2 levels: (1) dataScroller itself using `render` attribute; (2) step controls like `stepControls="show" fastControls="#{bean.rowCount/refData.recordsPerPage > 10 ? 'show' : 'hide'}" fastStep="10"`. – Vasil Lukach May 20 '14 at 14:35
  • Thanks Vasil for your response. I am not interested in controlling the display of the datascroller. I want the datascroller to be displayed all the time. However in certain scenarios (say, the associated datatable is editable, I want to prevent the user from navigating within the table until he has saved his modifications), I want to conditional stop the user from navigating away. I want to show a prompt to inform him about dirty data and let him decide whether he wants to move or not. If the user decides not to move, the scroller should not navigate to the requested page. – Vinay R May 21 '14 at 05:07

0 Answers0