Pergunta

I am developing a Seam-Jsfv1.2-EJB3 web app. I have a datatable and checkboxes in each row. Moreover, I have a datascroller at the bottom of my table as well.

My problem is when I click the next page number from the scroller, the selected checkboxes at the first page of the datatable is gone. I mean, even if they were selected, clicking the next page make them deselected. I see it by going back to the first page again by clicking the scroller.

Do you have any idea about that problem? In order to clearify my case, I attached my code below:

<rich:dataTable
            id="apiV2ProductList" rows="10" var="_apiV2Product"
            value="#{apiV2ProductList.resultList}"
            rendered="#{not empty apiV2ProductList.resultList}" reRender="ds">
            <rich:column>
                <f:facet name="header"> 
                    <h:selectBooleanCheckbox id="selectionCheckAll" onclick="selectAll()" /> 
                </f:facet>
                <h:selectBooleanCheckbox id="selectionCheck" onclick="increase(this)" value="#{_apiV2Product.selectValue}" >  
                </h:selectBooleanCheckbox>
            </rich:column>

...

<f:facet name="footer">
                <rich:datascroller id="ds" renderIfSinglePage="false">
                </rich:datascroller>
            </f:facet>

Many thanks in advance. Baris

Foi útil?

Solução 2

Adding an a4j support tag between scroller has solved my problem:

<f:facet name="footer">
  <rich:datascroller id="ds" renderIfSinglePage="false">
   <a4j:support event="onpagechange"/> 
  </rich:datascroller>
</f:facet>

However the other thing is, I am using JQuery to style my table (ex. on mouse over and out), and this time, when I click the next page of my table, the style is gone.

Any help would be great, many thanks in advance.

** PS: BTW the wierest thing to my mind is it comes me impossible to find a solution by yourself for this kind of problems. Your creation may not always be enough to solve (at least here in my example, adding a4j:support thing) I am asking experts, how can we handle that kind of things by ourselves... **

Outras dicas

You can extend the org.richfaces.renderkit.html.DatascrollerTemplate write your own DataScroller for your own styling by adding a component with the below configuration in faces-config.xml

<component>
    <component-type>exCustHtmlDatascroller</component-type>
    <component-lass>org.jsf.common.ui.EXCustHtmlDatascroller</component-class>
</component>
<render-kit>
  <renderer>
      <component-family>org.richfaces.Datascroller</component-family>
      <renderer-type>exCustDataScrollerTemplate</renderer-type>
      <renderer- class>org.jsf.common.ui.EXCustDataScrollerTemplate</renderer-class>
  </renderer>
</render-kit>

You don't need jQuery for styling the datatable

<rich:dataTable id="dataTable" var="x"  
onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"

The problem you were seeing with the styles being removed is due to the nature of AJAX, and the way the table is reRendered.

Assuming you were firing the initial styling call based on some form of page onLoad, the first time the page is rendered, your styles will be applied. However, when you click the "next" button with the paginator, you are pulling a lot of new HTML down, and replacing the old HTML in the table with the newer, updated information. The proble you're seeing is that you saw styling because jQuery applied styles to the old nodes, upon reRender, those nodes are completely thrown away, along with their styling. You simply need to figure out the hook to call the "styling" method, and re-execute that call after the table is re-rendered.

Generally, I use an a4j:status tag, and set up the onstart or onstop to re-parse the table.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top