3 Replies Latest reply on Jul 19, 2012 8:08 AM by sivaprasad9394

    h:commandLink not worked in rich:popupPanel+rich:dataTable

    sabarinathsss

      Hi

       

      I m using h:commandLink in rich:dataTable(rich:dataTable is present inside the rich:popupPanel)

       

      Page :

       

      <rich:popupPanel id="popupPanel" autosized="true"

         rendered="true" >

         <f:facet name="controls">

          <h:outputLink value="#" onclick="#{rich:component('popupPanel')}.hide(); return false;">

                          X

                      </h:outputLink>

         </f:facet>

         <h:panelGrid id="Grid">

          <rich:dataTable  value="#{sampleBean.dataDetail.dataList}" var="result" rows="5" reRender="demoScroller" rowClasses="odd-row,even-row">

         

           <rich:column>

            <f:facet name="header">

             <h:outputText value="Filename" />

            </f:facet>

            <h:commandLink rendered="true" id="filedownload" value="#{result.get('FileName')}" execute="@this" action="#{sampleBean.downloadBordereauFile()}">

             <f:param value="#{result.get('FileName')}" name="FileName"></f:param>

             <f:param value="#{result.get('FileLocation')}" name="FileLocation"></f:param>

            </h:commandLink>

           <f:facet name="footer">

            <rich:dataScroller id="demoScroller"></rich:dataScroller>

           </f:facet>

          </rich:dataTable>

          <a4j:commandButton value="Cancel" onclick="#{rich:component('popupPanel')}.hide();"></a4j:commandButton>

         </h:panelGrid>

        </rich:popupPanel>

       

      The h:commandLink not displayed in the rich:dataTable.

       

      if i use a4j:commandLink instead of h:commandLink then the filename is displayed but the file is not downloaded.

       

      Bean:

       

      public void downloadBordereauFile() throws Exception

      {

        HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse(); 

        Map<String,String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();    

        this.setFileName(params.get("FileName"));

        this.setFilePath(params.get("FileLocation"));   

        response.setHeader("Content-disposition","attachment;filename="+this.getFileName());

        File file=new File(this.getFilePath(),this.getFileName());

        try {

        

         sendFile(file,response);

        }catch (Exception exception) {

        throw new Exception (exception.getMessage());

        }

       

      }

       

       

      private void sendFile(File fileOut, HttpServletResponse response) throws Exception

      {

          response.setContentType("application/vnd.ms-excel");

        FileInputStream fis = new FileInputStream(fileOut);

        BufferedInputStream bis = new BufferedInputStream(fis);

        int ch=0;

        byte[] buf = new byte[10000];

        try{

        

         while((ch = bis.read(buf)) >= 0) {

         

          response.getOutputStream().write(buf,0,ch);

         }

        }catch (Exception exception) {

        

        throw new Exception (exception.getMessage());

        }

        finally{

        

         response.getOutputStream().flush(); 

         response.getOutputStream().close();

         bis.close();

         fis.close();

        }

       

      }

       

      Regards,

      Sabarinath

        • 1. Re: h:commandLink not worked in rich:popupPanel+rich:dataTable
          healeyb

          Try rich:popupPanel domElementAttachment="form" ...

           

          Regards,

          Brendan.

          • 2. Re: h:commandLink not worked in rich:popupPanel+rich:dataTable
            sabarinathsss

            Hi Brendan Healey,

             

            I m tried with rich:popupPanel domElementAttachment="form"  but now also h:commandLink not displayed in the rich:dataTable.

             

            Regards

            S.Sabarinath

            • 3. Re: h:commandLink not worked in rich:popupPanel+rich:dataTable
              sivaprasad9394

              Try adding  h:form for the model panel

              OR

              Use a4j:commandButton ,there also you can pass the param or assign using java script.

               

              <a:commandButton  value="Next >>" actionListener="#{feedbackDetailHome.validateFormFieldsFirstPopUp}"

                                  reRender="outputpanelID,feedbackPopUp,categoryFirstField,commentFirst,dateFirst,fromField"                     

                                  style="text-align:center" oncomplete="if(#{feedbackDetailHome.flagshowMSecondPanel})Richfaces.showModalPanel('feedbackPopUp');">  

                               <f:param name="docLibraryDocId"

                                          value="#{feedbackDetailHome.hiddenParamDocdId}"/> 

                              </a:commandButton>

               

              Thanks,

              Siva