@Rasika,
> She's still getting the same error. Then I suggested just try and see > the output of hardcoding the desired url into "url" parameter. > *url*: " > https://192.168.1.2:9443/bpmn-explorer/send?req=/bpmn/runtime/tasks/15048/attachments > <https://www.google.com/url?q=https%3A%2F%2F192.168.1.2%3A9443%2Fbpmn-explorer%2Fsend%3Freq%3D%2Fbpmn%2Fruntime%2Ftasks%2F15048%2Fattachments&sa=D&sntz=1&usg=AFQjCNGtlHGgHQIkEKjRr4tnkFlGAySrqw> > ", > ..... > }) > Still getting the same error. $('#attachForm').ajaxForm({ > If it is the *exact* error as mentioned above, then probably it is due to caching. @Himasha, One other option is to submit the form directly to the backend webapp (without interfering with java-script). In ML we had to go for java-script since we needed to set some custom headers to the request. Here I don't see such a requirement, hence you may avoid javascript and use "action" attribute of the html form.. Thanks, Supun On Sat, Jun 20, 2015 at 11:37 AM, Rajith Vitharana <[email protected]> wrote: > Hi Himasha, > > I was able to do that file uploading with below code sample. > > Below is the client side ajax call > > function addAttachment(id){ > > var data = new FormData(); > jQuery.each(jQuery('#files')[0].files, function(i, file) { > data.append('file-'+i, file); > }); > > jQuery.ajax({ > url: '/test3/endpoint.jag', > data: data, > cache: false, > contentType: false, > processData: false, > type: 'POST', > success: function(data){ > alert(data); > } > }); > } > > and below is the way to read the file inside jaggery app.(endpoint.jag) > > var file = request.getFile("file-0"); > file.open("r"); > var message = ""; > message = file.readAll(); > log.info("file content "+message); > file.close(); > > Thanks, > > > On Sat, Jun 20, 2015 at 11:31 AM, Rasika Perera <[email protected]> wrote: > >> Hi Nirmal & all, >> >> I suppose below error is getting due to conflicting of the "url" >> parameter defined by user and "url" >> parameter inside "ajaxForm" method. >> >> >>> Caused by: org.mozilla.javascript.WrappedException: Wrapped >>> java.lang.IllegalArgumentException: >>> Invalid uri '*http://192.168.1.2:9763null'*: invalid port number >>> (<<http>>/META-INF/scripts/http.js#220) >> >> >> >> var *url* = "/" + CONTEXT + "/send?req=/bpmn/runtime/tasks/" + id + >> "/attachments"; >> $('#attachForm').ajaxForm({ >> *url*: httpUrl + *url* >> , >> ..... >> }) >> >> So I suggested; >> >> var >> >> *serviceUrl*= "/" + CONTEXT + "/send?req=/bpmn/runtime/tasks/" + id + >> "/attachments"; >> $('#attachForm').ajaxForm({ >> *url*: httpUrl + >> *serviceUrl* >> , >> ..... >> }) >> >> She's still getting the same error. Then I suggested just try and see >> the output of hardcoding the desired url into "url" parameter. >> >> $('#attachForm').ajaxForm({ >> *url*: " >> https://192.168.1.2:9443/bpmn-explorer/send?req=/bpmn/runtime/tasks/15048/attachments >> <https://www.google.com/url?q=https%3A%2F%2F192.168.1.2%3A9443%2Fbpmn-explorer%2Fsend%3Freq%3D%2Fbpmn%2Fruntime%2Ftasks%2F15048%2Fattachments&sa=D&sntz=1&usg=AFQjCNGtlHGgHQIkEKjRr4tnkFlGAySrqw> >> ", >> >> ..... >> }) >> >> Still getting the same error. So three things needs to be clarified. >> >> 1. Does HTML form has an action parameter which affects the jQuery >> .ajaxForm method. >> 2. Any javascript that replaces the value of url parameter? >> 3. Is it a problem with caching? >> >> >> Thank you >> >> On Sat, Jun 20, 2015 at 10:54 AM, Himasha Guruge <[email protected]> >> wrote: >> >>> Hi Nirmal, >>> >>> it passes the intended url to send the form data. >>> var httpUrl = location.protocol + "//" + location.host; ( >>> https://192.168.1.2:9443) >>> var url = "/" + CONTEXT + "/send?req=/bpmn/runtime/tasks/" + id + >>> "/attachments"; >>> >>> On Sat, Jun 20, 2015 at 10:44 AM, Nirmal Fernando <[email protected]> >>> wrote: >>> >>>> >>>> >>>> On Sat, Jun 20, 2015 at 9:47 AM, Himasha Guruge <[email protected]> >>>> wrote: >>>> >>>>> Hi All, >>>>> >>>>> In order to send an input file using Ajax I'm using [1] which is also >>>>> used in ES and ML . My ajax call looks like following where the url value >>>>> is ( >>>>> https://192.168.1.2:9443/bpmn-explorer/send?req=/bpmn/runtime/tasks/15048/attachments >>>>> ). >>>>> >>>>> $('#attachForm').ajaxForm({ >>>>> url: httpUrl + url, >>>>> >>>> What does the above line do? >>>> >>>> >>>>> success : function(res){ >>>>> window.location = httpUrl + "/" + CONTEXT + "/inbox"; >>>>> >>>>> }, >>>>> error : function(res){ >>>>> var errorText = res.responseText >>>>> alert('ERROR' + errorText); >>>>> } >>>>> >>>>> }); >>>>> >>>>> When clicking on submit button of form, it goes to error function and >>>>> i'm getting following exception trace on console. >>>>> >>>>> Caused by: org.mozilla.javascript.WrappedException: Wrapped >>>>> java.lang.IllegalArgumentException: Invalid uri ' >>>>> *http://192.168.1.2:9763null'*: invalid port number >>>>> (<<http>>/META-INF/scripts/http.js#220) >>>>> >>>>> at >>>>> org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1754) >>>>> >>>>> at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:148) >>>>> >>>>> at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:386) >>>>> >>>>> at >>>>> org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32) >>>>> >>>>> at >>>>> org.jaggeryjs.rhino.<<http>>.META_INF.scripts.c0._c_anonymous_5(<<http>>/META-INF/scripts/http.js:220) >>>>> >>>>> at >>>>> org.jaggeryjs.rhino.<<http>>.META_INF.scripts.c0.call(<<http>>/META-INF/scripts/http.js) >>>>> >>>>> at >>>>> org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63) >>>>> >>>>> at >>>>> org.jaggeryjs.rhino.<<http>>.META_INF.scripts.c0._c_anonymous_8(<<http>>/META-INF/scripts/http.js:232) >>>>> >>>>> at >>>>> org.jaggeryjs.rhino.<<http>>.META_INF.scripts.c0.call(<<http>>/META-INF/scripts/http.js) >>>>> >>>>> at >>>>> org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63) >>>>> >>>>> at >>>>> org.jaggeryjs.rhino.bpmn_explorer.controller.c4._c_script_0(/bpmn-explorer/controller/communication.jag:39) >>>>> >>>>> at >>>>> org.jaggeryjs.rhino.bpmn_explorer.controller.c4.call(/bpmn-explorer/controller/communication.jag) >>>>> >>>>> at >>>>> org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394) >>>>> >>>>> at >>>>> org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091) >>>>> >>>>> at >>>>> org.jaggeryjs.rhino.bpmn_explorer.controller.c4.call(/bpmn-explorer/controller/communication.jag) >>>>> >>>>> at >>>>> org.jaggeryjs.rhino.bpmn_explorer.controller.c4.exec(/bpmn-explorer/controller/communication.jag) >>>>> >>>>> at >>>>> org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:567) >>>>> >>>>> ... 41 more >>>>> >>>>> Caused by: java.lang.IllegalArgumentException: Invalid uri >>>>> 'http://192.168.1.2:9763null': invalid port number >>>>> >>>>> at >>>>> org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:222) >>>>> >>>>> at >>>>> org.apache.commons.httpclient.methods.ExpectContinueMethod.<init>(ExpectContinueMethod.java:93) >>>>> >>>>> at >>>>> org.apache.commons.httpclient.methods.EntityEnclosingMethod.<init>(EntityEnclosingMethod.java:119) >>>>> >>>>> at >>>>> org.apache.commons.httpclient.methods.PostMethod.<init>(PostMethod.java:106) >>>>> >>>>> at >>>>> org.jaggeryjs.hostobjects.xhr.XMLHttpRequestHostObject.send(XMLHttpRequestHostObject.java:472) >>>>> >>>>> at >>>>> org.jaggeryjs.hostobjects.xhr.XMLHttpRequestHostObject.jsFunction_send(XMLHttpRequestHostObject.java:284) >>>>> >>>>> at sun.reflect.GeneratedMethodAccessor82.invoke(Unknown Source) >>>>> >>>>> at >>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) >>>>> >>>>> at java.lang.reflect.Method.invoke(Method.java:601) >>>>> >>>>> at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126) >>>>> >>>>> I can't figure out what's being passed as null, because when analyzing >>>>> the request file binary value is sent as expected. Any ideas/hints on what >>>>> could be the issue would be appreciated. >>>>> >>>>> Thanks, >>>>> Himasha Guruge >>>>> *Software Engineer* >>>>> WS*O2* *Inc.* >>>>> Mobile: +94 777459299 >>>>> [email protected] >>>>> >>>>> _______________________________________________ >>>>> Dev mailing list >>>>> [email protected] >>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>>> >>>>> >>>> >>>> >>>> -- >>>> >>>> Thanks & regards, >>>> Nirmal >>>> >>>> Associate Technical Lead - Data Technologies Team, WSO2 Inc. >>>> Mobile: +94715779733 >>>> Blog: http://nirmalfdo.blogspot.com/ >>>> >>>> >>>> >>> >>> >>> -- >>> Himasha Guruge >>> *Software Engineer* >>> WS*O2* *Inc.* >>> Mobile: +94 777459299 >>> [email protected] >>> >>> _______________________________________________ >>> Dev mailing list >>> [email protected] >>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>> >>> >> >> >> -- >> With Regards, >> >> *Rasika Perera* >> Software Engineer >> M: +94 71 680 9060 E: [email protected] >> LinkedIn: http://lk.linkedin.com/in/rasika90 >> >> WSO2 Inc. www.wso2.com >> lean.enterprise.middleware >> >> _______________________________________________ >> Dev mailing list >> [email protected] >> http://wso2.org/cgi-bin/mailman/listinfo/dev >> >> > > > -- > Rajith Vitharana > > Software Engineer, > WSO2 Inc. : wso2.com > Mobile : +94715883223 > Blog : http://lankavitharana.blogspot.com/ > > _______________________________________________ > Dev mailing list > [email protected] > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- *Supun Sethunga* Software Engineer WSO2, Inc. http://wso2.com/ lean | enterprise | middleware Mobile : +94 716546324
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
