3 Replies Latest reply on Sep 11, 2009 4:51 AM by Emil

    Adding a4j:region around a4j:commandLink in dataTable -  act

    Emil Newbie

      Hi!

      Been browsing the net in order to find a solution for my problem without any success. Most people have problem with commandLinks within dataTables in request scope without the keepAlive or other solutions that are out there.

      This is not my problem, everything works just fine until i add an a4j:region around my a4j:commandLink. The reason I add the region is to get a a4j:status to work correctly.

      I've tried to add ajaxSingle, limitToList, immediate etc. but the action in the commandLink is never called. If i use a h:commandLink it works, but then it reloads the page which isn't a desired behaivour.

      <rich:column>
      <a4j:region id="cmdRegion">
       <a4j:outputPanel styleClass="expand-link">
       <a4j:commandLink id="expandLink" value="LINK_EXPAND" action="#{myBean.detailsAction}" reRender="someOutputPanel" rendered="#{myBean.someLogic">
       <f:param name="messageId" value="#{dataTableItem.id}"/>
       </a4j:commandLink>
       </a4j:outputPanel>
      </a4j:region>
      </rich:column>


      rich:messages doesn't indicate any problems, can't see any strange in my server log.

      Has anyone experienced this before? I didn't thought, adding a a4j:region could decrease the odds of getting an successful action call.

        • 1. Re: Adding a4j:region around a4j:commandLink in dataTable -
          Nick Belaevski Master

          Hi,

          I cannot reproduce the problem using RF 3.3.1.GA. Please post full page code and version information.

          • 2. Re: Adding a4j:region around a4j:commandLink in dataTable -
            Emil Newbie

            Im using RF 3.3.1 GA, JSF 1.2 and Facelets 1.1.14.

            Here's the full (code in second datatable removed) page code. The bean extends SerializableDataModel if this is of interest.

            <ui:composition template="../includes/layout.xhtml"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:h="http://java.sun.com/jsf/html"
             xmlns:a4j="http://richfaces.org/a4j"
             xmlns:rich="http://richfaces.org/rich"
             xmlns:c="http://java.sun.com/jstl/core">
            
             <ui:define name="title">#{pagebundle['showFlows.title']}</ui:define>
             <ui:define name="head">
             <style type="text/css">
             .greyHeader {
             text-align:center;color:#7D7D7D;font-size:11px;font-weight:bold;display:block;
             }
             </style>
            </ui:define>
            <ui:define name="content">
            <f:loadBundle basename="web.flows" var="flowsbundle" />
            <a4j:keepAlive beanName="myBean"/>
            
            <a4j:form id="form">
            <rich:panel id="messagelog" style="width:742px">
             <f:facet name="header">
             <h:outputText value="#{flowsbundle['showFlows.messages']}"/>
             </f:facet>
             <a4j:status id="messagelogstatus" for="searchRegion">
             <f:facet name="start">
             <a4j:outputPanel id="statusPanel" style="text-align:center;display:block">
             <h:graphicImage value="/images/ajax/ajax-loader_indicator_big.gif" style="margin:30px"/>
             </a4j:outputPanel>
             </f:facet>
             <f:facet name="stop">
             <a4j:outputPanel id="messageOutputPanel">
             <rich:dataTable id="logs" columns="7" value="#{myBean}"
             var="item" rowClasses="tableFirstRow,tableFirstRow,tableSecondRow,tableSecondRow"
             rows="20" cellpadding="0" cellspacing="0"
             columnClasses="noSpaceColumn" styleClass="table-gradient-style"
             style="overflow:hidden;width:100%;padding:0px;margin:0px;">
             <!-- col 1 -->
             <rich:column>
             <f:facet name="header">
             <h:outputText value=""/>
             </f:facet>
             <h:graphicImage rendered="#{item.ok}" value="/images/icons/green_light_dark_bg.gif"/>
             <h:graphicImage rendered="#{item.warning}" value="/images/icons/yellow_light_dark_bg.gif"/>
             <h:graphicImage rendered="#{item.error}" value="/images/icons/red_light_dark_bg.gif"/>
             </rich:column>
             <!-- col 2 -->
             <rich:column>
             <f:facet name="header">
             <h:outputText value="#{flowsbundle['showFlows.timestamp']}"/>
             </f:facet>
             <h:outputText value="#{item.logtimedate}">
             <f:convertDateTime type="both" pattern="yyyy-MM-dd HH:mm:ss"/>
             </h:outputText>
             </rich:column>
             <!-- col 3 -->
             <rich:column>
             <f:facet name="header">
             <h:outputText value="#{generalbundle['status']}"/>
             </f:facet>
             <h:outputText value="#{item.status}"/>
             </rich:column>
             <!-- col 4 -->
             <rich:column>
             <f:facet name="header">
             <h:outputText value="#{flowsbundle['showFlows.sender']}"/>
             </f:facet>
             <h:outputText value="#{item.senderRoutingParty.description}"/>
             </rich:column>
             <!-- col 5 -->
             <rich:column>
             <f:facet name="header">
             <h:outputText value="#{flowsbundle['showFlows.receiver']}"/>
             </f:facet>
             <h:outputText value="#{item.receiverRoutingParty.description}"/>
             </rich:column>
             <!-- col 6 -->
             <rich:column>
             <f:facet name="header">
             <h:outputText value="#{generalbundle['type']}"/>
             </f:facet>
             <h:outputText value="#{item.routingMessagetype.description}"/>
             </rich:column>
             <!-- col 7 -->
             <rich:column style="padding:0px;width:25px;">
             <!-- Works just fine without this region -->
             <a4j:region id="expandRegion">
             <a4j:outputPanel styleClass="expand-link">
             <!-- Image link, image declared in CSS -->
             <a4j:commandLink id="expandLink" value="LINK_EXPAND" action="#{visibilityBean.detailsAction}" reRender="messageOutputPanel" immediate="true" rendered="#{visibilityBean.selectedMessageLogId!=item.id}">
             <f:param name="messageId" value="#{item.id}"/>
             </a4j:commandLink>
             <h:messages showDetail="true" showSummary="true"/>
             </a4j:outputPanel>
             </a4j:region>
             <a4j:outputPanel styleClass="minimize-link">
             <a4j:commandLink value="LINK_MINIMIZE" styleClass="minimize-link" action="#{myBean.detailsAction}" reRender="messageOutputPanel" immediate="true" rendered="#{myBean.selectedMessageLogId==item.id}">
             <f:param name="messageId" value=""/>
             <h:graphicImage value="/images/icons/minimize_details_16x10.png" style="vertical-align:middle;border:0px;" alt="#{flowsbundle['showFlows.minimize']}"/>
             </a4j:commandLink>
             </a4j:outputPanel>
             </rich:column>
             <!-- col 8 (new line under the other 7 columns) -->
             <rich:column id="col8" breakBefore="true" colspan="7" width="100%"
             style="margin:0px;padding:0px;background-color:#FFFFFF;background-image:none;">
             <!-- Want to point to the above commandLink from this status with the for attribute, hence I need the above region. -->
             <a4j:status id="detailsStatus" forceId="true">
             <f:facet name="start">
             <a4j:outputPanel style="text-align:center;display:block">
             <h:graphicImage value="/images/ajax/ajax-loader_indicator_big.gif" style="margin:30px"/>
             </a4j:outputPanel>
             </f:facet>
             <f:facet name="stop">
             <a4j:outputPanel rendered="#{myBean.selectedMessageLogId==item.id}">
             <h:outputText value="#{flowsbundle['showFlows.messageDetails']}" styleClass="greyHeader"/>
             <h:outputText rendered="false" value="item.id = #{item.id}"/>
             <h:panelGrid styleClass="detailsGrid" columns="2">
             <h:panelGrid columnClasses="rowHeader, secondRow" columns="2" style="overflow:hidden;width:280px;">
             <h:outputText value="#{flowsbundle['showFlows.messageId']}: "/>
             <h:outputText value="#{myBean.selectedMessageLog.secondaryId}"/>
             <h:outputText value="#{flowsbundle['showFlows.sendingCompany']}: "/>
             <h:outputText value="#{myBean.selectedMessageLog.senderRoutingParty.company.name}"/>
             <h:outputText value="#{flowsbundle['showFlows.receivingCompany']}: "/>
             <h:outputText value="#{myBean.selectedMessageLog.receiverRoutingParty.company.name}"/>
             </h:panelGrid>
             <h:panelGrid columnClasses="rowHeader, secondRow" columns="2" style="overflow:hidden;">
             <h:outputText value="#{flowsbundle['showFlows.incomingFile']}: "/>
             <h:outputText value="#{myBean.selectedMessageLog.infile}"/>
             <h:outputText value="#{flowsbundle['showFlows.outgoingFile']}: "/>
             <h:outputText value="#{myBean.selectedMessageLog.outfile}"/>
             </h:panelGrid>
             </h:panelGrid>
            
             <div class="divider"/>
             <rich:dataTable id="detailsTable" styleClass="detailsTable"
             value="#{myBean.eventsForSelectedMessage}" var="item1" rowKeyVar="rowKey"
             ajaxKeys="#{myBean.detailsKeys}"
             style="width:716px;margin:0px;padding:0px;margin-bottom:5px;margin-left:10px;margin-top:5px;">
            
             <! -- Another dataTable, have omitted the code for now -->
             </rich:dataTable>
             </a4j:outputPanel>
             </f:facet>
             </a4j:status>
             </rich:column>
             <f:facet name="footer">
             <rich:datascroller for="logs" maxPages="15" styleClass="table-gradient-footer"/>
             </f:facet>
             </rich:dataTable>
             </a4j:outputPanel>
             </f:facet>
             </a4j:status>
            </rich:panel>
            </a4j:form>
            </ui:define>
            </ui:composition>
            


            Looking in the server log (with phaseListener) I get the following:

            Without <4j:region> around the <a4j:commandLink>:

            _ThreadID=32;_ThreadName=httpSSLWorkerThread-443-2;|BEFORE RESTORE_VIEW 1|#]
            
            _ThreadID=32;_ThreadName=httpSSLWorkerThread-443-2;|AFTER RESTORE_VIEW 1|#]
            
            _ThreadID=32;_ThreadName=httpSSLWorkerThread-443-2;|BEFORE APPLY_REQUEST_VALUES 2|#]
            
            _ThreadID=32;_ThreadName=httpSSLWorkerThread-443-2;|+++ isRowAvailable()|#]
            
            _ThreadID=32;_ThreadName=httpSSLWorkerThread-443-2;|+++ setRowKey()|#]
            
            _ThreadID=32;_ThreadName=httpSSLWorkerThread-443-2;|+++ isRowAvailable()|#]
            
            _ThreadID=32;_ThreadName=httpSSLWorkerThread-443-2;|+++ walk()|#]
            
            ... Fetching data for DB ....
            
            _ThreadID=32;_ThreadName=httpSSLWorkerThread-443-2;|+++ in detailsAction|#]
            
            |AFTER APPLY_REQUEST_VALUES 2|#]
            
            _ThreadID=32;_ThreadName=httpSSLWorkerThread-443-2;|BEFORE RENDER_RESPONSE 6|#]
            


            And the following is when <a4j:region> is used:

            _ThreadID=29;_ThreadName=httpSSLWorkerThread-443-0;|AFTER RENDER_RESPONSE 6|#]
            
            _ThreadID=33;_ThreadName=httpSSLWorkerThread-443-3;|BEFORE RESTORE_VIEW 1|#]
            
            _ThreadID=33;_ThreadName=httpSSLWorkerThread-443-3;|AFTER RESTORE_VIEW 1|#]
            
            _ThreadID=33;_ThreadName=httpSSLWorkerThread-443-3;|BEFORE APPLY_REQUEST_VALUES 2|#]
            
            _ThreadID=33;_ThreadName=httpSSLWorkerThread-443-3;|AFTER APPLY_REQUEST_VALUES 2|#]
            
            _ThreadID=33;_ThreadName=httpSSLWorkerThread-443-3;|BEFORE PROCESS_VALIDATIONS 3|#]
            
            _ThreadID=33;_ThreadName=httpSSLWorkerThread-443-3;|AFTER PROCESS_VALIDATIONS 3|#]
            
            _ThreadID=33;_ThreadName=httpSSLWorkerThread-443-3;|BEFORE UPDATE_MODEL_VALUES 4|#]
            
            _ThreadID=33;_ThreadName=httpSSLWorkerThread-443-3;|AFTER UPDATE_MODEL_VALUES 4|#]
            
            _ThreadID=33;_ThreadName=httpSSLWorkerThread-443-3;|BEFORE INVOKE_APPLICATION 5|#]
            
            _ThreadID=33;_ThreadName=httpSSLWorkerThread-443-3;|AFTER INVOKE_APPLICATION 5|#]
            
            _ThreadID=33;_ThreadName=httpSSLWorkerThread-443-3;|BEFORE RENDER_RESPONSE 6|#]
            
            _ThreadID=33;_ThreadName=httpSSLWorkerThread-443-3;|+++ isRowAvailable()|#]
            
            _ThreadID=33;_ThreadName=httpSSLWorkerThread-443-3;|+++ setRowKey()|#]
            
            _ThreadID=33;_ThreadName=httpSSLWorkerThread-443-3;|+++ isRowAvailable()|#]
            
            _ThreadID=33;_ThreadName=httpSSLWorkerThread-443-3;|+++ walk()|#]
            
            ... And the detailsAction method in the bean is never called ....
            


            Can it be related to the use of the SerializableDataModel or is it due to the region blocking out necessary information?

            Best regards,
            Emil

            • 3. Re: Adding a4j:region around a4j:commandLink in dataTable -
              Emil Newbie

              Still havent solved this problem.

              Tried to remove the region around the a4j:commandLink and instead put a region around the a4j:status in order to get a a4j:status rendered for every table row (since a4j:status seem to skip the id:s of the table rows. For example its named form:table:status and not form:table:row1:status).

              When I move the region the a4j:commandLink works just fine again, but then another commandLink in the other dataTable stops working since this one is then included by the a4j:region.

              So problem remains with the region, but I'm also interested if there is a way to get the a4j:status id to inherit an parent id from another component (which is suitable to use for each table row) than the region?

              Best regards,
              Emil