-
1. Re: External AJAX access to webremote?
whafrog Dec 12, 2007 10:26 PM (in response to whafrog)Since it appears I can't get a functioning EntityManager in my servlet (I can get an entity manager, but can't inject a UserTransaction or get an EntityTransaction from the entity manager)...any suggestions? I basically want to expose a method on a stateless bean, accept a couple of parameters, and return straight XML to the awaiting javascript...
Anyone? Please?
:-) -
2. Re: External AJAX access to webremote?
whafrog Dec 12, 2007 11:13 PM (in response to whafrog)For those interested:
All the examples I was looking at used @Resource to inject the UserTransaction into the servlet, but it was always null. This works better:ut = (UserTransaction)context.lookup("java:comp/UserTransaction");
I wish there was a better way though. -
3. Re: External AJAX access to webremote?
shane.bryzak Dec 12, 2007 11:28 PM (in response to whafrog)The remoting stubs should work, just make sure you specify the absolute url to them.
-
4. Re: External AJAX access to webremote?
shane.bryzak Dec 12, 2007 11:33 PM (in response to whafrog)Oh, and you also need to override the Seam.Remoting.resourcePath after you import the script. It defaults to "/appname/seam/resource/remoting", so you'll need to give it an absolute url also:
Seam.Remoting.resourcePath = "http://localhost:8080/appname/seam/resource/remoting"
Make sure this line comes after the import! -
5. Re: External AJAX access to webremote?
dakna Dec 13, 2007 9:24 AM (in response to whafrog)I'm also interested in this topic, and with a quick search I came up with this thread:
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4069622#4069622
Maybe in this case it is also a cross domain policy problem, because of the different http port (80) of your static pages in comparison to your app server port (8080). Besides that, what about your static customer pages? I guess they don't have the same domain, so this is also not possible due to cross domain policy.
btw, I would love to see Seam remoting supporting this like EXT JS does:
http://extjs.com/deploy/ext/docs/output/Ext.data.ScriptTagProxy.html
No hands on experience on that, let me know if I'm wrong. -
6. Re: External AJAX access to webremote?
whafrog Dec 13, 2007 2:43 PM (in response to whafrog)"shane.bryzak@jboss.com" wrote:
Oh, and you also need to override the Seam.Remoting.resourcePath after you import the script. It defaults to "/appname/seam/resource/remoting", so you'll need to give it an absolute url also...
According to the Firefox javascript console, "Seam is not defined". Here's my whole page, which is just a file on my drive (not deployed). It's pointing to a deployed app:<html> <head> <script type="text/javascript" src="http://localhost:8080/myapp/seam/resource/remoting/resource/remote.js"></script> <script type="text/javascript" src="http://localhost:8080/myapp/seam/resource/remoting/interface.js?myservice"></script> <script type="text/javascript"> function getStuff() { alert(Seam.Remoting.resourcePath); Seam.Remoting.resourcePath = "http://localhost:8080/myapp/seam/resource/remoting"; alert(Seam.Remoting.resourcePath); Seam.Component.getInstance("myservice").getStuff("param1", "param2", getStuffCallback) alert("called"); } function getStuffCallback(result) { alert(result); } </script> </head> <body> Seam Remote Test:<br/> <hr/> <button onclick="javascript:getStuff()">Get Stuff</button> </body> </html>
I trust my web.xml file is set up properly:<servlet> <servlet-name>Seam Resource Servlet</servlet-name> <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Seam Resource Servlet</servlet-name> <url-pattern>/seam/resource/*</url-pattern> </servlet-mapping>
Anything in there that might get in the way? Security?
Thanks to dakna for the other thread, crossing domains may be an issue in future, but I'd like to prove it can work within-domain :-) -
7. Re: External AJAX access to webremote?
shane.bryzak Dec 13, 2007 6:21 PM (in response to whafrog)If you browse directly to http://localhost:8080/myapp/seam/resource/remoting/resource/remote.js does it work?
-
8. Re: External AJAX access to webremote?
whafrog Dec 14, 2007 11:10 AM (in response to whafrog)Now that I included jboss-seam-remoting.jar...yes. (doh! slap!)
Different issue now, both IE and Firefox have security issues. I'm logged in to my work via VPN, it must think "localhost" is a different domain. In IE I can enable the session, in Firefox I get a red "Please wait..." box in the upper right of the page, and an error on the console:Error: uncaught exception: Permission denied to call method XMLHttpRequest.open
I can get past the "Please wait..." by adding the following code to my javascript method:if (window.XMLHttpRequest) { // Mozilla, Safari,... try { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); } catch (e) { alert("Permission UniversalBrowserRead denied."); return null; } }
However, then I get this in the javascript console:Error: [Exception... "'Permission denied to get property XMLDocument.documentElement' when calling method: [nsIOnReadyStateChangeHandler::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "<unknown>" data: no]
Any way around that?
I've rewritten this service as a servlet. I still end up with the same domain-change security issues, but don't have a problem reading the data from my home-rolled javascript. So I'm wondering if there's a bug in the Seam javascript? -
9. Re: External AJAX access to webremote?
whafrog Dec 14, 2007 6:08 PM (in response to whafrog)For those interested, Seam appears to be using the XmlHttpRequest.responseXML property, but this triggers a Firefox/javascript/security problem, in that you aren't allowed to access the XML version of the data you're requesting.
You can, however, get the raw text, do your own reparsing, and play as you please:// hack, since Firefox won't allow access to responseXML var xmlDoc = (new DOMParser()).parseFromString(xmlHttpRequest.responseText, "text/xml");
Perhaps the Seam remoting libraries should incorporate this... -
10. Re: External AJAX access to webremote?
pmuir Dec 18, 2007 1:43 PM (in response to whafrog)File a feature request in jira