1

Hi I would like to know how can I define the targets of based on the action result.

I have the next action:

struts.xml:

<action name="download" class="com.XXX.XXX.webapp.DownloadAction">
        <result name="success" type="stream">
          <param name="contentType">application/octet-stream</param>
          <param name="inputName">inputStream</param>
          <param name="contentDisposition">attachment;filename="${fileName}"</param>
          <param name="bufferSize">4096</param>
        </result>
         <result name="input">/WEB-INF/pages/XXX/downloadDoc.jsp</result>
</action>

downloadDoc.jsp:

...
..
<s:div id="div_to_charge">
        <s:form id="formDownload" action="download">   
        ...
        ..
            <sj:submit
            button="true"
            targets="div_to_charge"
            formIds="formDownload"/>
        </s:form>
        ...

</s:div>
...
..

I need to charge the input result in the same pop-up, for this reason I put the targets in the <sj:submit>. But the problem It´s when the action result it´s SUCCESS , because it print the stream inside the <div>

Can I define the targets based on result name?

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
allen_ajd3
  • 35
  • 8
  • **Completely** unclear. [`INPUT` result](http://stackoverflow.com/a/23450365/1654265) is a different thing from the InputStream of the stream result type. Then, you are targeting the same div you are within, and then complaining because your actual HTML is gone... just target another div, no ? The rest is even less clear – Andrea Ligios Nov 28 '14 at 09:51
  • OK I think it´s not strange. I´m using a pop-up (with the content of downloadDoc.jsp) that display a lot of documents to be downloaded with a submit. The action "download" must check some validations before download all (size, number of files) and this possible message errors must to be in the same pop-up, for this reason I tried to change the targets based on action result name. NOTE: I´m using tiles and this pop-up it´s over other loaded content, for this reason I use the targets in the submit form – allen_ajd3 Nov 28 '14 at 11:29
  • Still not clear. Apart for the usage of the term *Pop-up* that is old-fashioned (pop ups were new windows with reduced capabilities: no menu, no resize ecc), while I guess you are talking of an Overlay (a "virtual" popup composed by just html in the same tab/window), you are also saying you download multiple files at once, that is not possible without using a ZIP or something. Your requirement is not strange, the question description is... as it is, it's hard to help you with just the code provided. – Andrea Ligios Nov 28 '14 at 12:41
  • Sorry for use the term pop-up, it´s not correct. I want to say dialog ("") it´s not a new tab, this dialog it´s rendered in the same tab over other content. This dialog shows a list of documents to be downloaded after submit. The problem it´s not to create the zip, the problem it´s to change the target if the result action name it´s "INPUT". I have to show inside this dialog the actionErrors released from the action Do you understand now? – allen_ajd3 Nov 28 '14 at 13:36
  • Yes. Not an easy topic BTW: you may want to take a look at this very nice plugin http://stackoverflow.com/a/9970672/1654265 (check out the demo). Instead of the alerts, you can manipulate the HTML to add your error message. Otherwise, there are tricky solutions – Andrea Ligios Nov 28 '14 at 16:48
  • Thanks for this link I'm trying to use it in my project. What is the other "tricky solution"?. Thanks ! – allen_ajd3 Dec 01 '14 at 16:03
  • Ok I have tested this plugin but it's not exactly that I need. This plugin can show a message error when the download fail (Error 500), but I need to know the fail from the response(size exceeded, num files selected exceeded,.. ). @AndreaLigios do you know other posible solutions ?. Thanks for your help – allen_ajd3 Dec 02 '14 at 07:37
  • Sorry for the late. The argument is not easy, and using overlays brings a bit more complexity and problems, like this one. You could try returning a JSON with the error messages in case of INPUT (instead of the JSP snippet you are returning now), then manually setting the messages to the main page with javascript in case of error. Or you can return a JSP snippet with a – Andrea Ligios Dec 03 '14 at 08:54
  • Hi @AndreaLigios thanks for your help. I have found other solution but I think it´s very particular to my functional case. This dialog has a jQuery grid and it uses JSON, I have added this messages in this JSON and with onCompleteTopics (jQ grid) I check this to show or not the errors in the same POP-UP. NOTE: Very usefull in jQGrid the 'userdata' param.
    Thanks !
    – allen_ajd3 Dec 03 '14 at 09:42
  • Glad to hear that, nicely done – Andrea Ligios Dec 03 '14 at 09:47

0 Answers0