Where The Streets Have No Name

[dojo] HelloWorld 본문

Developement/Web

[dojo] HelloWorld

highheat 2007. 12. 3. 15:14
<html>
  <head>
    <title>Dojo: Hello World!</title>
    <!-- SECTION 1 -->
    <style type="text/css">
        @import "./dojo-release-1.0.0/dijit/themes/tundra/tundra.css";
        @import "./dojo-release-1.0.0/dojo/resources/dojo.css"
    </style>
    <script type="text/javascript" src="./dojo-release-1.0.0/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
    <script type="text/javascript">
       // Load Dojo's code relating to the Button widget
       dojo.require("dijit.form.Button");

       function helloCallback(data,ioArgs) {
          alert(data);
       }       
       
       function helloError(data, ioArgs) {
          alert('Error when retrieving data from the server!');
       }

    </script>
  </head>
  <body class="tundra">
      <button dojoType="dijit.form.Button" id="helloButton">
          Hello World!
          <script type="dojo/method" event="onClick">
           alert('You pressed the button');
      </script>
      </button>
      
      <button dojoType="dijit.form.Button" id="serverCallButton">
          서버호출
          <script type="dojo/method" event="onClick">
               dojo.xhrGet({
            url: 'response.txt',
            load: helloCallback,
            error: helloError
               });
            </script>
      </button>
      
      <button dojoType="dijit.form.Button" id="getButton">
        서버호출Get
        <script type="dojo/method" event="onClick">
        dojo.xhrGet({
           url: 'HelloWorldResponseGET.jsp',
           load: helloCallback,
           error: helloError,
           content: {name: dojo.byId('name').value }
        });
        </script>
     </button>
     Please enter your name: <input type="text" id="name">
      <br>
      <form id="myForm" method="POST">
      Please enter your name: <input type="text" name="name2">
    </form>
    <button dojoType="dijit.form.Button" id="postButton">
          서버
          <script type="dojo/method" event="onClick">
            dojo.xhrPost({
            url: 'HelloWorldResponsePOST.jsp',
            load: helloCallback,
            error: helloError,
            form: 'myForm'
               });
            </script>
      </button>
  </body>
</html>

# jsp source
<%
  /*
  ' HelloWorldResponseGET.jsp
  ' --------
  '
  ' Print the name that is passed in the
  ' 'name' GET parameter in a sentence
  */

  response.setContentType("text/plain");
%>
Hello <%= request.getParameter("name") %> , welcome to the world of Dojo!