Changes between Version 7 and Version 8 of UTGBCore/RequestDispatcher


Ignore:
Timestamp:
10/04/07 18:57:46 (18 years ago)
Author:
leo
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UTGBCore/RequestDispatcher

    v7 v8  
    6969redirects requests to public folder or servlet codes.   
    7070
     71* tomcat/webapps/ROOT/WEB-INF/web.xml (the web app configuration file used in GWT-hosted mode)
     72{{{
     73<?xml version="1.0" encoding="UTF-8"?>
     74<web-app>
     75
     76        <servlet>
     77                <servlet-name>shell</servlet-name>
     78                <servlet-class>com.google.gwt.dev.shell.GWTShellServlet</servlet-class>
     79        </servlet>
     80       
     81
     82  <servlet-mapping>
     83    <servlet-name>shell</servlet-name>
     84    <url-pattern>/*</url-pattern>
     85  </servlet-mapping>
     86 
     87</web-app>
     88
     89}}}
     90
    7191GWTShellServlet is mandatory to debug client-side codes within within Eclipse (or other IDEs).
    72 
    7392
    7493Thus, there is no way to use following web.xml setting effectively.
     
    7695<url-pattern>*.action</url-pattern>
    7796}}}
    78 Even if you put the avobe setting
    79 into tomcat/ROOT/WEB-INF/web.xml, it does not work because of the mapping /* to GWTShellServlet overshadows other mappings.
     97Even if you put the avobe setting into tomcat/webaps/ROOT/WEB-INF/web.xml, it does not work because of the mapping /* to GWTShellServlet overshadows other mappings.
    8098
     99In order to use RequestDispatcher, which support rappid web application development, we introduce some tricks that
     100changes query arguments to the RequestDispather.
    81101
     102First, you have to set a servlet path within your GWT module xml file. (*.gwt.xml):
     103{{{
     104<module>
    82105
     106        <!-- Inherit the core Web Toolkit stuff.                  -->
     107                <inherits name="org.utgenome.gwt.web.Web"/>
     108                <inherits name='com.google.gwt.user.User'/>
     109                <inherits name="com.google.gwt.json.JSON"/>
     110                <inherits name="com.google.gwt.http.HTTP"/>
     111                <inherits name="com.google.gwt.xml.XML"/>
     112        <!-- Specify the app entry point class.                   -->
     113        <entry-point class='org.utgenome.gwt.utgb.client.UTGBResourceCenter'/>
     114   
     115   <servlet path="/dispatcher" class="org.utgenome.gwt.utgb.server.RequestDispatcher"/>
     116   
     117</module>
     118}}}
    83119
     120This setting redirects a request to GWT.getModuleBaseURL() + "/dispatcher" to the RequestDispatcher servlet. This is effective only in GWT-hosted mode!
     121
     122And write a URL resolver methods, described as follows:
     123{{{
     124    public static String getActionURL(String actionName, String queryString)
     125    {
     126        if(GWT.isScript())
     127        {
     128            return GWT.getModuleBaseURL() + actionName + ".action?" + queryString;
     129        }
     130        else
     131        {
     132            return GWT.getModuleBaseURL() + "dispatcher?actionClass=" + "org.utgenome.gwt.utgb.server.app." + actionName + "&" + queryString;
     133        }
     134    }
     135}}}
     136
     137This method yields appropriate URLs to access the RequestDispatcher both in hosted-mode and web-mode.
     138For example, getActionURL("hello", "name=leo") returns:
     139 * (GWT moduleBase)/hello.action?name=leo  (in web-mode)
     140 * (GWT moduleBase)/dispatcher?actionClass=org.utgenome.gwt.utgb.server.app.hello&name=leo   (in hosted-mode)
     141