java - How to call Struts2 action from no submit button -


i need know how call struts2 action button not submit form. when click on button should call struts2 action make web service call ssrs server (sql server reporting services). server sends report stream put in response. displays popup download pdf file. jsf it's easy, commandbutton provides "action" attribute. i'd equivalent of this:

<h:commandbutton id="editbutton" value="edit" action="#{mybean.edit}" />

public class mybean { public string edit() call web service, put stream on response return "ok"}}

how in struts2? ajaxa? jquery? dojo? new struts2 , ajax, lot of jsf.

thank you

without submitting form, need ajax.

but since need download pdf, perform call action returns stream result (and won't change current page).

read more here

specifying contentdisposition: attachment, ask user download file (or application use open it), while contentdisposition: inline open inside browser, changing page (that not want).

then specify action in url , use anchor tag

<s:url action="downloadaction.action" var="url">     <s:param name="param1">value1</s:param> </s:url> <s:a href="%{url}" >download</s:a> 

and in struts.xml

<result name="success" type="stream">    <param name="contenttype">application/pdf</param>    <param name="contentdisposition">attachment;filename="yourpdf.pdf"</param> </result> 

in action need provide (through getter) inputstream called inputstream.

edit

if want button, asked in comments:

<input  type = "button"         value = "download"       onclick = "javascript:location.href='downloadaction.action';" /> 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -