GWT: How to extract a content of a javascript function using (JSNI) -
i calling javascript function gwt client side using jsni follow:
anchor.addclickhandler(new clickhandler() { public void onclick(clickevent event) { execute(notification.getactioncode(), notification.getparams()); } }); private static native string execute(string functionname, string params)/*-{ try{ $wnd[functionname](params); }catch(e){ alert(e.message); } }-*/;
my problem javascript function contains window.open("servletname?...."). when clicking on anchor, window opened error below: the requested resource (/es/gwt/core/servletname) not available.
if replace window.open("servletname?....") window.open("../../servletname?...."), window open successfully, these javascript functions used outside gwt cant modify .
i dont know why part /gwt/core being added url causing problem. there way in gwt before executing javascript function, extract content , adding "../.." before url? i mean heaving javascript function name, can content before calling execute function? in case javascript function follow:
function everlinked_addspace(spaceid){ window.open('elutilities?service=space&action=homepage&spaceid='+spaceid+'&template=apps/everlinked/templates/spaces/space_main.htm','_blank');; }
i need modify in gwt client side , call new modifications.
i appreciate if me.
i think trying resolve problem using bad approach.
the easier way use url re-writer, or modify web.xml url-pattern
route relative path sent gwt app same servlet.
probably have in web.xml this:
<servlet> <servlet-name>myservlet</servlet-name> <servlet-class>maynamespace.servletname</servlet-class> </servlet> <servlet-mapping> <servlet-name>myservlet</servlet-name> <url-pattern>/servletname</url-pattern> </servlet-mapping>
so can add block web.xml.
<servlet-mapping> <servlet-name>myservlet</servlet-name> <url-pattern>/es/gwt/core/servletname</url-pattern> </servlet-mapping>
note url-pattern
has limited set of regular expressions (/path/* , *.ext), in case have write full path.