1 Reply Latest reply on Nov 21, 2010 10:02 AM by yangyang566566.yangyang566566.163.com

    About seam remoting problem

    yangyang566566.yangyang566566.163.com

      I am unable to Get remoting return value,  GetXMLAction class is my xml document to parse the contents,I want to use remoting to GetXMLAction class the return value of content back to the client,  Then the return value nested in the foreground page
      Sorry for the bad english :)


      Server-side code:



      package org.domain.tohtml.action; 
      import java.io.FileInputStream; 
      import java.io.IOException; 
      import java.io.PrintWriter; 
      import java.util.Set; 
      
      import javax.servlet.http.HttpServletRequest; 
      import javax.servlet.http.HttpServletResponse; 
      
      import org.jboss.seam.annotations.Name; 
      import org.jboss.seam.annotations.remoting.WebRemote; 
      
      @Name("getxmlaction") 
      public class GetXMLAction { 
      
      @WebRemote 
        public String  OutPutHtml( String con) throws IOException 
        { 
               String file = ""; 
      String filePath="E:/eclipse/workspace/tohtml/WebContent/test.xml"; 
      FileInputStream fileinputstream = new FileInputStream(filePath); 
      int lenght = fileinputstream.available(); 
      byte bytes[] = new byte[lenght]; 
      fileinputstream.read(bytes); 
      fileinputstream.close(); 
      
      String  content = new String(bytes);  
      
      return content; 
      } 
      } 






      Client code:



      <html xmlns="http://www.w3.org/1999/xhtml" 
        xmlns:ui="http://java.sun.com/jsf/facelets" 
        xmlns:h="http://java.sun.com/jsf/html" 
        xmlns:s="http://jboss.com/products/seam/taglib"> 
      
      
      <head> 
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
      
        <s:remote include="getxmlaction"/> 
        
        <script type="text/javascript">    
          function xmlinserthml() { 
              debugger; 
            var callback = function(result) { alert(result); }; 
            var value =  Seam.Component.getInstance ("getxmlaction").OutPutHtml();             
          } 
          function sayHelloCallback(result) { 
              alert(result); 
            } 
      
                      function showContent() 
                      { 
                      try 
                      { 
                      var responseXML = request.responseXML; 
                      var xmldom = responseXML.documentElement; 
                      document.getElementById("attribute").innerHTML =   xmldom.childNodes.item(0).getAttribute("attribute"); 
                       document.getElementById("content").innerHTML = xmldom.childNodes.item(0).childNodes.item(0).text; 
                      } 
                              catch(exception) 
                      {;} 
      
      } 
              
        </script>  
      </head> 
        <body onload="xmlinserthml()"> 
        <center> 
          <table align="center" border="0"> 
          <tr> 
          <td><strong><span id="attribute"> </span></strong></td> 
          </tr> 
          <tr> 
          <td><strong><span id="content"> </span></strong></td> 
          </tr> 
          </table> 
          </center> 
        </body> 
      </html> 
      





        • 1. Re: About seam remoting problem
          yangyang566566.yangyang566566.163.com

          yang yang wrote on Nov 21, 2010 10:01:


          I am unable to Get remoting return value,  GetXMLAction class is my xml document to parse the contents,I want to use remoting to GetXMLAction class the return value of content back to the client,  Then the return value nested in the foreground page.

          Sorry for the bad english :)


          Server-side code:


          package org.domain.tohtml.action; 
          import java.io.FileInputStream; 
          import java.io.IOException; 
          import java.io.PrintWriter; 
          import java.util.Set; 
          
          import javax.servlet.http.HttpServletRequest; 
          import javax.servlet.http.HttpServletResponse; 
          
          import org.jboss.seam.annotations.Name; 
          import org.jboss.seam.annotations.remoting.WebRemote; 
          
          @Name("getxmlaction") 
          public class GetXMLAction { 
          
          @WebRemote 
            public String  OutPutHtml( String con) throws IOException 
            { 
                   String file = ""; 
          String filePath="E:/eclipse/workspace/tohtml/WebContent/test.xml"; 
          FileInputStream fileinputstream = new FileInputStream(filePath); 
          int lenght = fileinputstream.available(); 
          byte bytes[] = new byte[lenght]; 
          fileinputstream.read(bytes); 
          fileinputstream.close(); 
          
          String  content = new String(bytes);  
          
          return content; 
          } 
          } 






          Client code:


          <html xmlns="http://www.w3.org/1999/xhtml" 
            xmlns:ui="http://java.sun.com/jsf/facelets" 
            xmlns:h="http://java.sun.com/jsf/html" 
            xmlns:s="http://jboss.com/products/seam/taglib"> 
          
          
          <head> 
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
          
            <s:remote include="getxmlaction"/> 
            
            <script type="text/javascript">    
              function xmlinserthml() { 
                  debugger; 
                var callback = function(result) { alert(result); }; 
                var value =  Seam.Component.getInstance ("getxmlaction").OutPutHtml();             
              } 
              function sayHelloCallback(result) { 
                  alert(result); 
                } 
          
                          function showContent() 
                          { 
                          try 
                          { 
                          var responseXML = request.responseXML; 
                          var xmldom = responseXML.documentElement; 
                          document.getElementById("attribute").innerHTML =   xmldom.childNodes.item(0).getAttribute("attribute"); 
                           document.getElementById("content").innerHTML = xmldom.childNodes.item(0).childNodes.item(0).text; 
                          } 
                                  catch(exception) 
                          {;} 
          
          } 
                  
            </script>  
          </head> 
            <body onload="xmlinserthml()"> 
            <center> 
              <table align="center" border="0"> 
              <tr> 
              <td><strong><span id="attribute"> </span></strong></td> 
              </tr> 
              <tr> 
              <td><strong><span id="content"> </span></strong></td> 
              </tr> 
              </table> 
              </center> 
            </body> 
          </html> 
          








          Click HELP for text formatting instructions. Then edit this text and check the preview.