Hi Sajith, Thanks for your reply. That cater the requirement.
Best Regards On Thu, Jan 5, 2017 at 10:07 AM, SajithAR Ariyarathna <sajit...@wso2.com> wrote: > Hi Indunil, > > Can you explain your exact requirement? Seems that what you want to do is, > save some data (obtained in a HTML form) using an OSGi service in a form > POST submit. > > If so, then you can do this in the onRequest function. Don't specify any > 'action' for your HTML form, so when you submit it the POST request goes to > the same page (URL). In the onRequest function of your page, you can > check whether the request is a POST or not with env.request.method == > "POST" condition. If that condition is true, then you can extract POST > parameters from the request and call the desired OSGi service. > > e.g. > > function onRequest(env) { > if (env.request.method == "POST") { > // this is a POST request, so lets call the OSGi service > callOSGiService("org.wso2.Foo", "barMethod", ["some", "parameters"]); > // more stuff you want to do ... > } > } > > Please refer the file upload sample [1][2] in the "Feature App" sample > (URL https://localhost:9292/Features-app/file-upload). > > [1] https://github.com/wso2/carbon-uuf/blob/v1.0.0-m7/ > samples/apps/org.wso2.carbon.uuf.sample.features-app/src/ > main/pages/file-upload.js > [2] https://github.com/wso2/carbon-uuf/blob/v1.0.0-m7/ > samples/apps/org.wso2.carbon.uuf.sample.features-app/src/ > main/pages/file-upload.hbs > > Thanks. > > > On Thu, Jan 5, 2017 at 9:41 AM, Indunil Upeksha Rathnayake < > indu...@wso2.com> wrote: > >> Hi, >> >> As mentioned in the Web App Developer’s Guide for Unified UI Framework >> [1], "callOSGiService" is a function call of a server side JS API. So that >> AFAIK, that can't be called from JS files in the public folder, where >> client side logic resides. >> I have requirement to call an OSGI service from a client side JS. Is it a >> way to do that using UUF? >> >> Following are the steps of the exact requirement. >> >> 1. Invoke an OSGI service in onRequest() and will be filled the >> content of .hbs from the value returned in onRequest(). >> 2. Have a "submit" button in .hbs, where the onClick function is been >> implemented in a JS resides in the "public" folder. >> 3. Inside the onClick function, need to call another OSGI service. >> >> Without implementing the onClick function in "public" folder, is there >> any other way to achieve that and call the OSGI service? >> >> >> And I would like to know how the "module" function works? Is that cater >> our requirement? Included module will be executed before the onRequest() >> method or after? Please share if there are any sample using the module >> function. >> >> [1] https://docs.google.com/document/d/10UDdArHV1eYEfiONu8saqPnn >> JyUjH3vxOrv0k0rK5hc/edit# >> >> Thanks and Regards >> -- >> Indunil Upeksha Rathnayake >> Software Engineer | WSO2 Inc >> Email indu...@wso2.com >> Mobile 0772182255 >> > > > > -- > Sajith Janaprasad Ariyarathna > Software Engineer; WSO2, Inc.; http://wso2.com/ > <https://wso2.com/signature> > -- Indunil Upeksha Rathnayake Software Engineer | WSO2 Inc Email indu...@wso2.com Mobile 0772182255
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev