8 Replies Latest reply: Aug 14, 2009 8:15 AM by Nick Belaevski RSS

a4j:repeat output garbled on repetitive requests

Steven De Groote Newbie

Guys,

I'm stuck with a fairly major problem on a page using a4j:repeat (nested in an a4j:outputPanel) and a datascroller to show the output. On the page is a form which upon submission shows a number of records in a self-written html structure with tables.

So far so go, submitting the form shows the results, paging works, etc. etc.

However, the layout of the results is completely garbled when the user submits the form again before the output is generated. A lot of td and tr elements are in the wrong place or added.

Do any of you know what may be causing this erroneous output?

Thanks,
Steven

  • 2. Re: a4j:repeat output garbled on repetitive requests
    Steven De Groote Newbie

    Ok well since this doesn't appear to be a known problem, here some code.

    Simplified jsp:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@ page contentType ="text/html; charset=UTF-8" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
    <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j" %>
    
    <f:view beforePhase="#{transactionDataDetailResults.beforePhase}">
     <c:set var="title" value="${msg.transactionDataDetail_title}" scope="request" />
     <jsp:include page="/includes/header.jsp"/>
     <h:messages errorClass="error" warnClass="warn" infoClass="info" />
     <h:form id="searchForm">
     <a4j:region renderRegionOnly="false">
     <table width="800px">
     <tr>
     <td width="230px">
     <h:outputLabel for="customer" value="#{msg.transactionDataDetail_customerNumber}:"></h:outputLabel>
     </td>
     <td width="220px">
     <h:selectManyListbox required="true" requiredMessage="#{msg.required_select_customer}" size="5" id="customer" value="#{transactionDataDetail.customer}" valueChangeListener="#{transactionDataDetail.changeSelection}" style="width:250px;">
     <a4j:support event="onchange" reRender="xmlLink,pdfLink,csvLink" ajaxSingle="true" />
     <f:selectItems value="#{transactionDataDetail.customerList}" />
     </h:selectManyListbox>
     </td>
     <td width="110px">
     <h:outputLabel for="make" value="#{msg.transactionDataDetail_make}:"></h:outputLabel>
     </td>
     <td width="210px">
     <h:selectOneListbox id="make" size="1" value="#{transactionDataDetail.makeId}" immediate="true" valueChangeListener="#{transactionDataDetail.changeSelection}">
     <a4j:support event="onchange" reRender="xmlLink,pdfLink,csvLink,model,type" limitToList="true" ajaxSingle="true" />
     <f:selectItems value="#{transactionDataDetail.vehicleMakeItems}"/>
     </h:selectOneListbox>
     </td>
     </tr>
     </table>
     </a4j:region>
    
     <h:commandButton id="runreport" action="#{transactionDataDetailResults.submit}" value="#{msg.runreport}" styleClass="button"/>
    
    
     <a4j:outputPanel id="presults" layout="block">
     <a4j:repeat id="resultview" binding="#{transactionDataDetailResults.cmpResults}" rows="5" value="#{transactionDataDetail.items}" var="result">
     <table width="90%" style="border: 1px solid #000">
     <tr>
     <td style="font-weight:bold">
     <h:outputText value="#{msg.transactionDataDetail_nummer}" /> 
     <h:outputLink value="masterdatadetail.jsf">
     <h:outputText value="#{result.contractnumber}"/>
     <f:param name="contractnr" value="#{result.contractnumber}" />
     <f:param name="ref" value="transactiondatadetail" />
     </h:outputLink>
     </td>
     <td style="font-weight:bold">
     <h:outputText value="#{msg.transactionDataDetail_contractstatus}" />  <h:outputText value="#{result.contractstatus}"></h:outputText>
     </td>
     <td style="font-weight:bold">
     <h:outputText value="#{msg.transactionDataDetail_servicecontractnumber}" />  <h:outputText value="#{result.servicecontractnumber}"></h:outputText>
     </td>
     <td style="font-weight:bold">
     <h:outputText value="#{msg.transactionDataDetail_licenseplate}" />  <h:outputText value="#{result.licenseplate}"></h:outputText>
     </td>
     </tr>
     </table>
    
     <table width="90%" style="margin-top:1em">
     <tr>
     <td width="45%" valign="top">
     <table width="100%" style="border: 1px solid #000">
     <tr>
     <td>
     <h:outputText value="#{msg.transactionDataDetail_driver} " /> <h:outputText value="#{result.fromdate}"/>
     </td>
     <td>
     <h:outputText value="#{result.driver}"/>
     </td>
     </tr>
     </table>
    
     <table width="100%" style="border: 1px solid #000;margin-top:1em">
     <tr>
     <td>
     <h:outputText value="#{msg.transactionDataDetail_excessdistancerm}" />
     </td>
     <td>
     <h:outputText value="#{result.excessdistancerm}">
     <f:convertNumber pattern="###,##0.000"/>
     </h:outputText>
     </td>
     </tr>
     </table>
     </td>
    
     <td width="45%" valign="top" align="right">
     <table width="100%" style="border: 1px solid #000;">
     <tr>
     <td width="120px">
     <h:outputText value="#{msg.transactionDataDetail_make}" />
     </td>
     <td>
     <h:outputText value="#{result.make}"/>
     </td>
     </tr>
     </table>
     </td>
     </tr>
     </table>
    
     <table width="90%" style="border: 1px solid #000;margin-top:1em">
     <tr>
     <td style="font-weight:bold" colspan="4">
     <h:outputText value="#{msg.transactionDataDetail_cutoffdate}" /> <h:outputText value="#{result.cutoffdate}"/>
     </td>
     <td style="font-weight:bold" colspan="4">
     <h:outputText value="#{msg.transactionDataDetail_nbrmonthsintocontract}"/> <h:outputText value="#{result.nbrmonthsintocontract}"><f:convertNumber pattern="#00"/></h:outputText> <h:outputText value="#{msg.transactionDataDetail_contractduration}" /> <h:outputText value="#{result.contractduration}"><f:convertNumber pattern="#00"/></h:outputText> <h:outputText value="#{msg.transactionDataDetail_monaten}" />
     </td>
     </tr>
     <tr>
     <td colspan="2"></td>
     <td colspan="2" style="font-weight:bold">
     <h:outputText value="#{msg.transactionDataDetail_costperiod}" />
     </td>
     <td colspan="5"></td>
     </tr>
     <tr>
     <td style="font-weight:bold">
     <h:outputText value="#{msg.transactionDataDetail_servicetype}" />
     </td>
     <td style="font-weight:bold">
     <h:outputText value="#{msg.transactionDataDetail_calculation}" />
     </td>
     <td style="font-weight:bold">
     <h:outputText value="#{msg.transactionDataDetail_startcostperiod}" />
     </td>
     <td style="font-weight:bold">
     <h:outputText value="#{msg.transactionDataDetail_endcostperiod}" />
     </td>
     <td style="font-weight:bold">
     <h:outputText value="#{msg.transactionDataDetail_outgoinginvserviceamount}" />
     </td>
     <td style="font-weight:bold">
     <h:outputText value="#{msg.transactionDataDetail_incominginvserviceamount}" />
     </td>
     <td style="font-weight:bold">
     <h:outputText value="#{msg.transactionDataDetail_servicedelta}" />
     </td>
     <td style="font-weight:bold">
     <h:outputText value="#{msg.transactionDataDetail_percservicedelta}" />
     </td>
     </tr>
     <a4j:repeat var="subresult" value="#{result.Cost_Set}" id="subreportresult">
     <tr>
     <td>
     <h:outputText value="#{subresult.servicetype}"/>
     </td>
     <td>
     <h:outputText value="#{subresult.calculation}"/>
     </td>
     <td>
     <h:outputText value="#{subresult.startcostperiod}"/>
     </td>
     <td>
     <h:outputText value="#{subresult.endcostperiod}"/>
     </td>
     <td style="text-align:right">
     <h:outputText value="#{subresult.outgoinginvserviceamount}">
     <f:convertNumber pattern="###,##0.00"/>
     </h:outputText>
     </td>
     <td style="text-align:right">
     <h:outputText value="#{subresult.incominginvserviceamount}">
     <f:convertNumber pattern="###,##0.00"/>
     </h:outputText>
     </td>
     <td style="text-align:right">
     <h:outputText value="#{subresult.servicedelta}">
     <f:convertNumber pattern="###,##0.00"/>
     </h:outputText>
     </td>
     <td style="text-align:right">
     <h:outputText value="#{subresult.percservicedelta}">
     <f:convertNumber pattern="##0.00%"/>
     </h:outputText>
     </td>
     </tr>
     </a4j:repeat>
     <tr>
     <td style="font-weight:bold;">
     <h:outputText value="#{msg.transactionDataDetail_total}" />
     </td>
     <td colspan="3"></td>
     <td style="font-weight:bold;text-align:right">
     <h:outputText value="#{result.Cost_Set[0].outgoing_inv_service_sum}" >
     <f:convertNumber pattern="###,##0.00"/>
     </h:outputText>
     </td>
     <td style="font-weight:bold;text-align:right">
     <h:outputText value="#{result.Cost_Set[0].incoming_inv_service_sum}" >
     <f:convertNumber pattern="###,##0.00"/>
     </h:outputText>
     </td>
     <td style="font-weight:bold;text-align:right">
     <h:outputText value="#{result.Cost_Set[0].servicedelta_sum}" >
     <f:convertNumber pattern="###,##0.00"/>
     </h:outputText>
     </td>
     <td style="font-weight:bold;text-align:right">
     <h:outputText value="#{result.Cost_Set[0].percservicedelta_sum}" >
     <f:convertNumber pattern="##0.00%"/>
     </h:outputText>
     </td>
     </tr>
     </table>
    
     <table width="40%" style="border:1px solid #000000; margin-top:1em">
     <tr>
     <td style="font-weight:bold" colspan="2">
     <h:outputText value="#{msg.transactionDataDetail_kilometerstande1}" />
     </td>
     </tr>
     <tr>
     <td>
     <h:outputText value="#{result.datelastrecordedmilage2}"/>
     </td>
     <td>
     <h:outputText value="#{result.lastrecordedmilage2}">
     <f:convertNumber pattern="###,##0"/>
     </h:outputText>
     </td>
     </tr>
     </table>
    
    
     </a4j:repeat>
     </a4j:outputPanel>
     <rich:datascroller id="scroller" align="center" reRender="presults" for="resultview" renderIfSinglePage="false" binding="#{transactionDataDetailResults.cmpDataScroller}" scrollerListener="#{transactionDataDetailResults.switchPage}" maxPages="20" />
     </h:form>
     <jsp:include page="/includes/footer.jsp"/>
    </f:view>
    
    


    It is basically everything in between the a4j:outputPanel tags that gets mixed up. Comparing the generated html source shows that most html table elements (table, td, tr tags) are doubled.

    eg. A piece of the normal output looks like this:
    <tr>
     <td>
    
     Aufbau
     </td>
     <td>
     KOMBI
     </td>
     </tr>
    


    And the problem output gives this:
     <tr>
     <td>
    
     </td>
     </tr>
     <tr>
     <td>
     Aufbau
     </td>
    
     <td>
    
     </td>
     <td>
     KOMBI
     </td>
     </tr>
    
    


    Also, transactionDataDetailResults is a bean on request scope, transactionDataDetail one on session scope (I split them because I had duplicate ID problems)

    Thanks

  • 3. Re: a4j:repeat output garbled on repetitive requests
    Ilya Shaikovsky Master

    add tbody elements to your tables.

  • 4. Re: a4j:repeat output garbled on repetitive requests
    Steven De Groote Newbie

    Hi,
    unfortuantely tbody's doesn't solve the problem.

    Here's what happens (note that the rendering elements are bound to a request bean, and that the results are stored in session bean to keep them for a while):
    1. first a submit request (POST), everything fine.
    2. then pressing the submit button quickly a few times => bad output
    3. after rendering, submit form again => still bad output
    4. when going to the page with a normal GET through a link => good output

    I'm a bit stunned that this is happening considering that the output components are in the request-managed bean. Any thoughts where I need to look?

    Thanks

  • 5. Re: a4j:repeat output garbled on repetitive requests
    Nick Belaevski Master

    This can be a concurrency problem. Have you tried adding a4j:queue?

  • 6. Re: a4j:repeat output garbled on repetitive requests
    Steven De Groote Newbie

    I was thinking the same, so I started experimenting with synchronizing some methods, so far without success.

    I'll check out the queue system, but I'm being told that this garbling also happens with other actions, not only by quickly hitting submit.

    I'll get back to you...

  • 7. Re: a4j:repeat output garbled on repetitive requests
    Steven De Groote Newbie

     

    "nbelaevski" wrote:
    This can be a concurrency problem. Have you tried adding a4j:queue?

    Btw... I don't think a queue will help here, my form submission request is a plain POST, no AJAX involved.

  • 8. Re: a4j:repeat output garbled on repetitive requests
    Nick Belaevski Master

    Then concurrent modification of transactionDataDetail is highly probable the cause of the issue.