1 Reply Latest reply on Jan 12, 2016 9:05 AM by liumin hu

    a4j:commandButton is  not firing the event in the Single Click.Only on Second Click event fired ???

    Siva P Master

      Hi,

       

      a4j:commandButton is not firing the event properly.only on second click event is fired properly.Why this behaviour is observed in Richfaces.

      After migrating my application this is the final and last bug?How to resolve it?Looks like some view state error.

       

      How can i apply for my ajax command link.??

       

      Richfaces Version : RichFaces Core Implementation by JBoss by Red Hat, version v.4.2.2.Final

      Jboss Version: JBoss EAP 6.2.0.GA (AS 7.3.0.Final-redhat-14)

      Seam: Seam 2.3.0.CR1

      JSF : Initializing Mojarra 2.1.19-jbossorg-1 20131024-0833 for context '/SimpleReporting'

       

       

      Here I have a nested form in the reporting.xhtml page which contains ui:include of tab_shortid_search.xhtml page.

       

      reporting.xhtml:


      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
          xmlns:s="http://jboss.org/schema/seam/taglib"
          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:rich="http://richfaces.org/rich"
          xmlns:a4j="http://richfaces.org/a4j" template="layout/template.xhtml">
          <ui:define name="body">
              <script type="text/javascript">
                  function disablementFunction(day) {
                      var curDt = new Date();
                      if (curDt == undefined) {
                          curDt = day.date.getDate;
                      }
                      if (curDt.getTime() >= day.date.getTime()) {
                          return true;
                      } else {
                          return false
                      }
                  }
              </script>
              <!-- <a4j:status id="mod" onstart="onRequestStart()"
                  onstop="onRequestEnd()" /> -->
                  <a4j:status for="reportingRegion"
                          onstart="#{rich:component('wait-dialog')}.show()"
                          onstop="#{rich:component('wait-dialog')}.hide()" />
              <rich:popupPanel id="wait-dialog" resizeable="false" autosized="false"
                  width="130" height="100" headerClass="popupborder" moveable="false"
                  shadowOpacity="0" style="overflow:hidden;">
                  <center>
                      <h:graphicImage value="/img/ajax_load.gif" width="70px"
                          height="70px" />
                  </center>
                  <br></br>
              </rich:popupPanel>
              <br></br> 
              <a4j:region id="reportingRegion">
              <rich:tabPanel id="results" switchType="client"
                  activeItem="#{reporting.selectedTab}" >
                  <rich:tab id="shortIdSearch" header="#{messages.shortidreporting}" value="#{reporting.selectedTab}"
                      actionListener="#{reporting.setFocusedShortIdActionListener}">
                      <h:form id="reportingFormSI" styleClass="view">
                          <h:panelGrid columns="1" width="100%" border="0">
                              <rich:panel bodyClass="inpanelBody" headerClass="cycleborder"
                                  styleClass="cycleborder">
                                  <f:facet name="header">#{messages.reporting}</f:facet>
                                  <table>
                                      <tr>
                                          <td width="100px"><b>#{messages.shortid}</b><s:span styleClass="required">*</s:span></td>
                                          <td colspan="3"><h:inputTextarea id="label" required="true"
                                                  value="#{reporting.focusedShortId}" cols="70">
                                              </h:inputTextarea>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td colspan="4"></td>
                                      </tr>
                                      <tr>
                                          <td style="vertical-align:middle"><b>Show Media?</b></td>
                                          <td colspan="3" style="vertical-align:middle"><h:selectBooleanCheckbox id="hidemedia"
                                                  value="#{reporting.includeMedia}" required="false"
                                                  converterId="javax.faces.Boolean">
                                                  <f:param name="includeMedia"
                                                      value="#{reporting.includeMedia}" />
                                              </h:selectBooleanCheckbox> <h:outputLabel value="#{messages.showmediacheck}" /></td>
                                      </tr>
                                      <tr>
                                          <td colspan="4"></td>
                                      </tr>
                                      <tr>
                                          <td style="vertical-align:middle"><b>From</b><s:span styleClass="required">*</s:span></td>
                                          <td style="vertical-align:middle"><rich:calendar id="fromdateSI" required="true"
                                              value="#{reporting.from}" datePattern="#{reporting.format}"
                                              boundaryDatesMode="select" isDayEnabled="disablementFunction">
                                          </rich:calendar>
                                          <f:param name="from" value="#{reporting.from}" /></td>
                                          <td style="vertical-align:middle"><b><h:outputText value="Until" /></b><s:span styleClass="required">*</s:span></td>
                                          <td style="vertical-align:middle"><rich:calendar id="untildateSI" required="true"
                                              value="#{reporting.until}" datePattern="#{reporting.format}"
                                              boundaryDatesMode="select" isDayEnabled="disablementFunction">
                                          </rich:calendar>
                                          <f:param name="until" value="#{reporting.until}" /></td>
                                      </tr>
                                      <tr>
                                          <td colspan="4"><br></br></td>
                                      </tr>
                                      <tr>
                                          <td></td>
                                          <td colspan="3"><a4j:commandButton id="reportingSI"
                                              value="#{messages.createreport}" type="submit"
                                              action="#{reporting.getShortIdReport()}" render="tableSI"
                                              actionListener="#{reporting.selectedTabSwitch}">
                                              <a4j:ajax render="outPanelshortId" execute="@form"></a4j:ajax>
                                          </a4j:commandButton>
                                          <s:link id="bl" value="bookmarkable link"
                                              includePageParams="true"></s:link></td>
                                      </tr>
                                  </table>
                                  <div style="clear: both" />
                              </rich:panel>
                              <a4j:outputPanel id="outPanelshortId">
                              <h:panelGroup id="tableSI" rendered="#{shortIdReport.rowCount>0}">
                                  <ui:include
                                      src="/layout/tab_shortid_search.xhtml">
                                      <ui:param id="dataSI" name="data" value="#{shortIdReport}" />
                                  </ui:include>
                              </h:panelGroup>
                              </a4j:outputPanel>
                          </h:panelGrid>
                      </h:form>
                  </rich:tab>
                  <rich:tab id="breadCrumbSearch" header="#{messages.breadcrumbreporting}" 
                      actionListener="#{reporting.setFocusedShortIdActionListener}" value="#{reporting.selectedTab}">
                      <h:form id="reportingForm" styleClass="view">
                          <h:panelGrid id="dataPanel" columns="1" width="100%">
                              <rich:panel bodyClass="inpanelBody" headerClass="cycleborder"
                                  styleClass="cycleborder">
                                  <f:facet name="header">#{messages.reporting}</f:facet>
                                  <table>
                                      <tr>
                                          <td width="100px"><b>Breadcrumb</b><s:span styleClass="required">*</s:span></td>
                                          <td colspan="3"><h:inputTextarea id="label"
                                                  required="true" cols="70" value="#{reporting.rb_countername}">
                                              </h:inputTextarea></td>
                                      </tr>
                                      <tr>
                                          <td colspan="4"></td>
                                      </tr>
                                      <tr>
                                          <td  style="vertical-align:middle"><b>Show Media?</b></td>
                                          <td  style="vertical-align:middle"><h:selectBooleanCheckbox id="hidemedia"
                                                  value="#{reporting.includeMedia}" required="false"
                                                  converterId="javax.faces.Boolean">
                                                  <f:param name="includeMedia"
                                                      value="#{reporting.includeMedia}" />
                                              </h:selectBooleanCheckbox> 
                                              <f:param name="recursive" value="#{reporting.recursive}" /></td>
                                          <td style="vertical-align:middle"><b><h:outputText value="Include subpages?"
                                              rendered="#{fromSiteStat}" /></b></td>
                                          <td style="vertical-align:middle"><h:selectBooleanCheckbox id="recursive"
                                                  value="#{reporting.recursive}" required="false"
                                                  converterId="javax.faces.Boolean" rendered="#{fromSiteStat}">
                                              </h:selectBooleanCheckbox> <f:param name="recursive" value="#{reporting.recursive}" /></td>
                                      </tr>
                                      <tr>
                                          <td colspan="4"></td>
                                      </tr>
                                      <tr>
                                          <td style="vertical-align:middle"><b>From</b><s:span styleClass="required">*</s:span></td>
                                          <td style="vertical-align:middle"><rich:calendar id="fromdateSI" required="true"
                                                  value="#{reporting.from}" datePattern="#{reporting.format}"
                                                  boundaryDatesMode="select" isDayEnabled="disablementFunction">
                                              </rich:calendar> <f:param name="from" value="#{reporting.from}" /></td>
                                          <td style="vertical-align:middle"><b>Until</b><s:span styleClass="required">*</s:span></td>
                                          <td style="vertical-align:middle"><rich:calendar id="untildateSI" required="true"
                                                  value="#{reporting.until}" datePattern="#{reporting.format}"
                                                  boundaryDatesMode="select" isDayEnabled="disablementFunction">
                                              </rich:calendar> <f:param name="until" value="#{reporting.until}" /></td>
                                      </tr>
                                      <tr>
                                          <td colspan="4"></td>
                                      </tr>
                                      <tr>
                                          <td></td>
                                          <td colspan="3"><a4j:commandButton id="reporting"
                                                  value="#{messages.createreport}" type="submit"
                                                  action="#{reporting.getReport()}" render="table"
                                                  actionListener="#{reporting.selectedTabSwitch}">
                                                  <a4j:ajax render="outPanelrecursive" execute="@form"></a4j:ajax>
                                              </a4j:commandButton> <s:link id="bl" value="bookmarkable link"
                                                  includePageParams="true"></s:link></td>
                                      </tr>
                                  </table>
                              </rich:panel>
                              <a4j:outputPanel id="outPanelrecursive">                
                              <h:panelGroup id="table"  rendered="#{report.rowCount>0}">
                                  <ui:include src="/layout/tab_shortid_search.xhtml">
                                      <ui:param id="data1" name="data" value="#{report}" />
                                  </ui:include>
                              </h:panelGroup>
                              </a4j:outputPanel>
                          </h:panelGrid>
                      </h:form>
                  </rich:tab>
              </rich:tabPanel>
              </a4j:region>
          </ui:define>
      
      </ui:composition>
      
      

       

       

       

      tab_shortid_search.xhtml


      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
          xmlns:s="http://jboss.org/schema/seam/taglib"
          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:xforms="http://www.w3.org/1999/xhtml"
          xmlns:c="http://java.sun.com/jstl/core">
          <rich:dataTable headerClass="header" id="data" var="_data" styleClass="datatableStyle"
              sortMode="single" value="#{data}" rows="15"
              style="xls-font: 10 Verdana; width:100%;  xls-column-widths: 8000 9000 10000"
              columnClasses="left, right" noDataLabel="No data could be found">
      
              <rich:column id="date" label="Date" headerClass="dataTableHeader"
                  sortBy="#{_data.requestDate}" style="width:6%;">
                  <f:facet name="header">
                      <h:outputText value="Date" style="xls-font: red bold" />
                  </f:facet>
                  <h:outputText value="#{_data.requestDate}">
                      <s:convertDateTime type="date" pattern="dd/MM/yyyy" />
                  </h:outputText>
              </rich:column>
      
              <rich:column id="cn" label="Breadcrumb" headerClass="dataTableHeader"
                  sortBy="#{_data.counterName.counterName}" style="text-align: left; width:50%;"
                  rendered="#{reporting.selectedTab.equals('breadCrumbSearch')}">
                  <f:facet name="header">
                      <h:outputText value="Breadcrumb" style="xls-font: red bold" />
                  </f:facet>
                  <div class="wrapword" id="breadcrumbvalue">
                      <h:outputLink target="_blank"
                          value="#{_data.counterName.shortid.shortid}">
                          <h:outputText value="#{_data.counterName.counterName}" />
                      </h:outputLink>
                      <rich:contextMenu showEvent="contextmenu" mode="client" target="cn">
                          <rich:menuItem >
                              <h:outputLink target="_blank" value="#{_data.counterName.shortid.shortid}">
                                  #{messages.gotoresource}
                              </h:outputLink>
                          </rich:menuItem>
                          <rich:menuItem>
                              <a4j:commandLink id="siReportButton1"
                                  action="#{reporting.setFocusedShortId(_data.counterName.shortid.shortid)}"
                                  value="#{messages.gotoshortid}"
                                  data="#{_data.counterName.shortid.shortid}"
                                  actionListener="#{reporting.setFocusedShortIdActionListener}"
                                  render="results,@form" limitRender="true" execute="@form">
                                  <f:setPropertyActionListener value="shortIdSearch"
                                      target="#{reporting.selectedTab}" />
                              </a4j:commandLink>
                          </rich:menuItem>
                      </rich:contextMenu>
                  </div>
              </rich:column>
            
              <rich:column id="cn1" label="Breadcrumb" headerClass="dataTableHeader"          
                  sortBy="#{_data.counterName.counterName}"
                  style="text-align: left; width:50%;"
                  rendered="#{!reporting.selectedTab.equals('breadCrumbSearch')}">
                  <f:facet name="header">
                      <h:outputText value="Breadcrumb" style="xls-font: red bold" />
                  </f:facet>
                  <div class="wrapword">
                      <h:outputLink target="_blank"
                          value="#{_data.counterName.shortid.shortid}">
                          <h:outputText value="#{_data.counterName.counterName}" />
                      </h:outputLink>
                  </div>
                  <rich:contextMenu showEvent="contextmenu" mode="client" target="cn1">
                      <rich:menuItem mode="client">
                          <h:outputLink target="_blank" value="#{_data.counterName.shortid.shortid}">
                              #{messages.gotoresource}
                          </h:outputLink>
                      </rich:menuItem>
                      <rich:menuItem>
                           <a4j:commandLink id="siReportButton2" type="button"
                              action="#{reporting.setRb_countername(_data.counterName.counterName)}"
                              value="#{messages.gotobreadcrumb}" data="#{_data.counterName.shortid.shortid}"           //This is the menu from the datatable,which is clicked.
                              actionListener="#{reporting.setFocusedShortIdActionListener}"
                              render="results,@form" limitRender="true" execute="@form">
                              <f:setPropertyActionListener value="breadCrumbSearch"
                                  target="#{reporting.selectedTab}" />
                          </a4j:commandLink>                  
                      </rich:menuItem>
                  </rich:contextMenu>
              </rich:column>
      
              <rich:column id="mimetype" label="Mimetype"
                  headerClass="dataTableHeader"
                  sortBy="#{_data.counterName.shortid.mimetype.fileextension}"
                  style="text-align: center; width:7%;">
                  <f:facet name="header">
                      <h:outputText value="Mimetype" style="xls-font: red bold" />
                  </f:facet>
                  <h:outputText
                      value="#{_data.counterName.shortid.mimetype.fileextension}" />
              </rich:column>
            
              <rich:column id="medianame" label="Media Name"
                  headerClass="dataTableHeader"
                  sortBy="#{_data.counterName.shortid.mediaName}"
                  style="text-align: center; width:14%;">
                  <f:facet name="header">
                      <h:outputText value="Media Name" style="xls-font:red bold"/>
                  </f:facet>
                  <h:outputLink target="_blank" value="#{_data.counterName.shortid.mediaShortID}">
                      <h:outputText value="#{_data.counterName.shortid.mediaName}" />
                  </h:outputLink>
                  <rich:contextMenu showEvent="contextmenu" mode="client" target="medianame" style="text-align: left;">
                      <rich:menuItem>
                          <h:outputLink target="_blank" value="#{_data.counterName.shortid.mediaShortID}">
                              #{messages.gotoresource}
                          </h:outputLink>
                      </rich:menuItem>
                      <rich:menuItem>
                          <a4j:commandLink id="mediareportlink"
                               value="#{messages.runmediareport}"
                              action="#{reporting.setFocusedShortId(_data.counterName.shortid.mediaShortID)}"
                              actionListener="#{reporting.setFocusedShortIdActionListener}"
                              data="#{_data.counterName.shortid.mediaShortID}"
                              render="results,@form" limitRender="true" execute="@form">
                              <f:setPropertyActionListener value="shortIdSearch"
                                  target="#{reporting.selectedTab}" />                          
                          </a4j:commandLink>
                      </rich:menuItem>
                  </rich:contextMenu>
              </rich:column>
            
              <rich:column id="cc" label="#{messages.language}" headerClass="dataTableHeader"
                  sortBy="#{_data.counterName.countryCode.countryCode}"          
                  style="text-align: center; width:7%;">
                  <f:facet name="header">
                      <h:outputText value="#{messages.language}" style="xls-font: red bold" />
                  </f:facet>
                  <h:outputText value="#{_data.counterName.countryCode.countryCode}" />
              </rich:column>
      
              <rich:column id="pvs" label="Visitors" headerClass="dataTableHeader"
                  sortBy="#{_data.pageVisitors}"          
                  style="text-align: right; width:6%;">
                  <f:facet name="header">
                      <h:outputText value="Visitors" style="xls-font: red bold" />
                  </f:facet>
                  <h:outputText value="#{_data.pageVisitors}" />
              </rich:column>
      
              <rich:column id="pr" label="Pagerequests"
                  headerClass="dataTableHeader"
                  sortBy="#{_data.pageRequests}"
                  style="text-align: right; width:10%;">
                  <f:facet name="header">
                      <h:outputText value="Pagerequests" style="xls-font: red bold" />
                  </f:facet>
                  <h:outputText value="#{_data.pageRequests}" />
              </rich:column>
      
              <f:facet name="footer">
                  <rich:dataScroller id="ds" for="data" renderIfSinglePage="true"
                      page="#{reporting.page}" />
              </f:facet>
          </rich:dataTable>
          <h:commandLink value="#{messages.exporttoexcel}"
              rendered="#{reporting.selectedTab.equals('breadCrumbSearch')}"
              action="#{reporting.generateExcel()}" />
          <h:commandLink value="#{messages.exporttoexcel}"
              rendered="#{reporting.selectedTab.equals('shortIdSearch')}"
              action="#{reporting.generateExcelByShortID()}" />
      </ui:composition>
      
      
      
      

       

      Images:

      Page_Report_1.png

      Page_Report_2.png

       

       

      How to resolve this problem???

      Thank you.