1 Reply Latest reply on Dec 3, 2010 5:57 PM by Shane Bryzak

    please tell me seam remoting didn't just screw me....

    willie slepecki Newbie

      ive got an app that im converting from php to seam.  most of it is based on ajax and most importantly the xmlhttpresponse object.  there is literally tens of thousands of lines of code that require that object.  so, because my ajax system is on a different domain in the network, in php i wrote about 10 lines of code that forwards the ajax request to the server and returns the xml string with the text/xml header and that gives my ajax its xmlhttp object and its a happy world.  i wrote a similar method in a stateless backing bean in seam.


      @WebRemote
           public String runAjax(String xml)
           {
           AjaxRequestTO req = AjaxRequestTO.xmlToClass(xml);
           AjaxResponseTO resp = new AjaxResponseTO();
      
                req.setServerURL(configBean.getShowhubUrl());
                try
                {
                     resp = ShowhubClient.runAjaxTrans(req);
                } catch (XmlRequiredFieldNotPresent xr)
                {
                     xr.printStackTrace();
                } catch (TransFailException tex)
                {
                     tex.printStackTrace();
                } catch (ConnectException e)
                {
                     e.printStackTrace();
                } catch (IOException e)
                {
                     e.printStackTrace();
                }
      
                return resp.toString();
           }



      and added a simple check in my javascript to see if my js files are running in seam or php (they have to run side by side in this project.  some of it is staying php) and if its seam calls this webremote method. 


      problem: php returns an xmlhttp object, seam returns a string object.  which breaks my entire ajax and javascript core. 


      i see two solutions
      1 - get seam remoting to return an xmlhttp object
      2 - detect if its seam, take that string thats returned and convert it to an xmlhttprequest object.  but im not sure thats possible yet.


      please help, this is due at close of business and im screwed without it.

        • 1. Re: please tell me seam remoting didn't just screw me....
          Shane Bryzak Master

          That's the whole point of Seam remoting, it abstracts away the underlying AJAX mechanics so that you can just work with your server side business methods and the values they return.




          2 - detect if its seam, take that string thats returned and convert it to an xmlhttprequest object. but im not sure thats possible yet.

          That won't work, the string that's returned is the result of your method invocation.  Can you explain why you need the XMLHttpRequest object?  Perhaps I can then suggest a solution.