4 Replies Latest reply on Jan 31, 2008 5:43 PM by Luis Miguel

    Open new window from modalpanel with commandlink

    Klaus Viehböck Newbie

      I am using a h:commandlink with the following code:

      
      <h:commandLink
       id="buttonDownloadAusschreibungAgonto"
       value="Jetzt runterladen!!!"
       target="test">
       <a4j:support event="onclick" action="#{ausschreibungsdokumenteDownloadHandler.downloadAusschreibung}"></a4j:support>
      </h:commandLink>
      
      
      


      but when i click the button no new Browserwindow is opened. When i look at the generated html code the "target" attribute of the generated tag is missing.
      I use Firefox 2.0 by the way

        • 1. Re: Open new window from modalpanel with commandlink
          Ilya Shaikovsky Master

          this construction is wrong from the beggining.. Click at this link wil generate two requests at one time one common and the other ajax one.

          • 2. Re: Open new window from modalpanel with commandlink
            Klaus Viehböck Newbie

            I forgot to say that i am trying to implement a download, where i call a Action method of a Handler that reads a binary file from the filesystem and writes it into the httpServletResponse.

            i also tried another solution without the a4j:support tag

            <a4j:form>
             <a4j:commandLink
             id="buttonDownloadAusschreibungAgonto"
             value="Jetzt runterladen!!!"
             target="test"
             action="#{ausschreibungsdokumenteDownloadHandler.downloadAusschreibung}">
             </a4j:commandLink>
            </a4j:form>
            


            With this solution the Action Method is invoked and the file is processed. But instead of opening a file dialog, the Browser shows the binary code of the file.

            So i tried to open a new windows with target attribute, that isnt generated in the HTML code

            I use the following settings for the httpHeader

             response.setContentType("application/x-download");
             response.setHeader("Content-disposition", "attachment; filename=\"" + downloadName + "\"");
             response.setContentLength((new Long(srcdoc.length())).intValue());
             response.setHeader("expires", "0");
            


            which seems to be correct. So i supposed that i might have a problem with richfaces

            • 3. Re: Open new window from modalpanel with commandlink
              Sergey Smirnov Master

              Ajax is a replacing the part of the browser DOM tree without reloading the whole page.

              So, you case is not suitable for Ajax. I just have to use the standard h:commandLink without any Ajax enhancements.

              • 4. Re: Open new window from modalpanel with commandlink
                Luis Miguel Newbie

                 

                "klaus.viehboeck" wrote:
                I am using a h:commandlink with the following code:
                <h:commandLink
                 id="buttonDownloadAusschreibungAgonto"
                 value="Jetzt runterladen!!!"
                 target="test">
                 <a4j:support event="onclick" action="#{ausschreibungsdokumenteDownloadHandler.downloadAusschreibung}"></a4j:support>
                </h:commandLink>
                

                but when i click the button no new Browserwindow is opened. When i look at the generated html code the "target" attribute of the generated <a/> tag is missing.
                I use Firefox 2.0 by the way


                I think that you should use this:

                <a4j:htmlCommandLink action="#{ausschreibungsdokumenteDownloadHandler.downloadAusschreibung}"/>