on 05-15-2014 8:27 AM
Hi Experts,
We are trying to submit form data to an external URL from Web Dynpro Java application. We are achieving this with the following piece of code.
try
{
strPrintContent="<html>"+
"<head>"+
"<script type=\"text/javascript\">"+
"function myfunc () "+
"{"+
"var frm = document.getElementById(\"paymentForm\");"+
"frm.submit();"+
"}"+
"</script>"+
"</head>"+
"<body onLoad=myfunc()>"+
"<form id=paymentForm method=post action=\""+merchantURLPart+"\">"+
"<INPUT type=hidden name=username value="+userName+">"+
"<INPUT type=hidden name=pass value="+passWord+">"+
"<INPUT type=hidden name=senderid value="+senderID+">"+
"<INPUT type=hidden name=dest_mobileno value="+mobile+">"+
"<INPUT type=hidden name=message value='"+msg+"'>"+
"<INPUT type=hidden name=response value="+response+">"+
"</form>"+
"</body>"+
"</html>";
IWDWebResource webResource = WDWebResource.getWebResource(strPrintContent.getBytes(),WDWebResourceType.HTML);
IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(webResource.getAbsoluteURL(),"WBSEDCL");
window.show();
}
catch(Exception e)
{
wdComponentAPI.getMessageManager().reportException("Error : "+e.toString(),false);
}
But it opens another window. We dont need that. We have to stay on the same window. Please suggest what can be done.
You can use Suspend-Resume Plug-in
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Suvankar,
U got any solution ???
If have any solution please let me know
Thanks & Regards,
Meghal Shah
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can create a HTML file with the request post parameters and the external URL something like this:
public java.lang.String GetRedirecturl( )
{
// External URL
String html = "<html><head></head><body onload=\"load()\"> " +
"<form id=\"form1\" action=\"https://www.abc.com/xyz.jsp\" method=\"POST\">" +
// Post Parameters
"<INPUT TYPE=\"HIDDEN\" NAME=\"Param1\"VALUE=\""+Param1Value+"\">"+
"<input name=\"sap-wd-resumeurl\" type=\"hidden\"/>" +
"</form> " +
"" +
"<script>" +
"function load(){" +
"var loc = window.location.search.substring(1);" +
"var queryString = loc.split(\"sap-wd-resumeurl=\");" +
"if(queryString.length > 0)" +
"{" +
"var resumeURL = queryString[1].split(\"&\");" +
"if(resumeURL.length >= 0)" +
"{" +
" document.forms['form1'].elements['sap-wd-resumeurl'].value= unescape(resumeURL[0])" +
"}" +
"}" +
"document.getElementById('form1').submit();" +
"}" +
"</script>" +
"</body> </html>";
String redirectUrl = "";
byte[] byteArrayHtmlData = null;
try {
byteArrayHtmlData = html.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
wdComponentAPI.getMessageManager().reportException("Internal error occurred. Please try after some time",true);
}
IWDResource htmlResource = WDResourceFactory.createCachedResource(new ByteArrayInputStream(byteArrayHtmlData), "Redirect.html", WDWebResourceType.HTML, true);
redirectUrl = htmlResource.getUrl(WDFileDownloadBehaviour.AUTO.ordinal());
return redirectUrl;
}
Hope this will be helpful.
Regards,
Anurag
If you are in NW7.3 version try using WebWidget UI for this requirement.
Mahesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use Java, something like this: http://kspace.in/blog/2008/05/30/submit-html-form-using-java/
Regards,
Omri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Suvankar,
you could try to add a "window.hide()" right after the "window.show". But i don't know what happens since it would be a show and a hinde in one roundtrip.
Also you coud create a html file which accepts your params via url and then does a post on load. Then you could call that html via IFrame and set the frame to 0 px so it would be invisible.
Or maybe add a message "Data send successfully" (or something equal) and a button "ok" to your generated HTML which closes the new external window and gives feedback to enduser.
Regards,
Tobi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.