Tuesday, July 27, 2010

Re: Creating a separate GWT servlet page

An entry-point is different than a servlet (Remote Procedure Call). A
RPC is used to change the page without refreshing, so you wouldn't
likely change your entry-point.

First of, I think cokol and mkh are right. You should have one entry
point and have the admin area a panel. You can check the session to
make sure the user has appropriate permissions before showing the
panel. Although, I think what you want would go something like this,
even though I have never done it before.

Your <projectName>.gwt.xml defines a module with an entry point. If
you want to create another module (kinda like a "project" in the same
project, as you put it), then you could duplicate this xml file and
name it something like AdminPage.get.xml.

<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='admin_area'>

<inherits name='class you want to inherit'/>

<entry-point class='com.projectname.admin.client.AdminPage.java'/>

<source path='client'/>
<source path='shared'/>

</module>

Now that you have another module, GWT will create another nocache.js
file. It should be called admin_area.nocache.js. Each HTML file will
specify what it's entry point is by which javasscript file it
inherits. So your new admin html page should include

<script type="text/javascript" language="javascript" src="admin_area/
admin_area.nocache.js"></script>

Now when that page is loaded, it will call the onModuleLoad() in
AdminPage.java.

To go from page to page, you can do something like

new HTML("<a href=\"+PATH+"Admin.html\"> Admin Page </a>");

Again, I have never done it before, but It might work how you want.
You'll have to play with the paths but give it a shot. Or someone
correct me if I'm way off =).

Tom

On Jul 26, 9:41 am, Irving Ruan <irvingr...@gmail.com> wrote:
> What would I need to do in web.xml to instantiate other entry-point
> classes?
>
> Right now, mine looks like thus:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE web-app
>     PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
>     "http://java.sun.com/dtd/web-app_2_3.dtd">
>
> <web-app>
>
>    <!-- Servlets -->
>   <servlet>
>     <servlet-name>rpcServlet</servlet-name>
>     <servlet-class>server.RPCCoreServiceImpl</servlet-class>
>   </servlet>
>
>   <servlet-mapping>
>     <servlet-name>rpcServlet</servlet-name>
>     <url-pattern>/web_app/rpcService</url-pattern>
>   </servlet-mapping>
>
>   <!-- Default page to serve -->
>   <welcome-file-list>
>     <welcome-file>WebApp.html</welcome-file>
>   </welcome-file-list>
>
> </web-app>
>
> Would I just add something like this:
>    <!-- Servlets -->
>   <servlet>
>     <servlet-name>adminServlet</servlet-name>
>     <servlet-class>client.AdminPanel</servlet-class>
>   </servlet>
>
>   <servlet-mapping>
>     <servlet-name>adminServlet</servlet-name>
>     <url-pattern>/web_app/adminPanel</url-pattern>
>   </servlet-mapping>
>
> And would I add entry point onModuleLoad in my AdminPanel.java?
>
> On Jul 23, 5:30 pm, mkh <mike.hana...@gmail.com> wrote:
>
> > You can certainly define multiple modules in one web app. I use
> > Intellij IDEA, and this is as simple as hitting Alt-Insert and picking
> > GWT/ Module.
>
> > The downside of doing this is the GWT compile time goes up directly
> > with the number of modules since each is processed independently.
>
> > On Jul 23, 2:45 pm, Irving Ruan <irvingr...@gmail.com> wrote:
>
> > > Sorry if that sounded confusing.
>
> > > Hopefully, this puts it in a perspective that can be understood:
>
> > > HTML-Entry Point class associations --
> > > Module1.html - Module1:EntryPoint.class,
> > > Module2.html - Module2:EntryPoint.class
>
> > > Would it be possible to create something like that, where you can have
> > > two separate projects or something and load two different entry point
> > > classes? Is there some easier way to achieve this without segregating
> > > it into two different projects and combining the output?
>
> > > The security party isn't really important as of this moment - but onto
> > > the previous issue: in order to keep it in one project, would I need
> > > to modify my web.xml to include different modules for each new .html
> > > page/entry point class?
>
> > > -I.
>
> > > On Jul 23, 6:37 am, mkh <mike.hana...@gmail.com> wrote:
>
> > > > The notion of pages in a GWT app for someone experiences with a
> > > > traditional web app (for example, a JSF based app) is definitely a bit
> > > > confusing.
>
> > > > The basic scheme of displaying different panels (in the same page) is
> > > > the GWT approach, but how would you handle the situation where the
> > > > "admin" section of the app needs to be protected by a security
> > > > constraint requiring the user to login before that portion of the app
> > > > is available? In JSF this is straight forward, based on the path. But
> > > > with GWT to have another path you would need to have another module
> > > > with another host page...
>
> > > > On Jul 23, 4:06 am, cokol <eplisc...@googlemail.com> wrote:
>
> > > > > what you mean by "page"? so you mean not actually an entry point or
> > > > > screen but rather a usual HTML page? then just write your .jsp , like
> > > > > adminPage.jsp. Or if you really want to write a panel with much HTML
> > > > > try using UiBinder.
>
> > > > > and remember - there is no "page" in GWT applications, however, you
> > > > > can combile html pages with GWT written UI. So if you want to design a
> > > > > second gwt-screen you just do so by createing a new panel (adminPanel)
> > > > > and just make in visible in the onClick() event of your menu or the
> > > > > trigger button.
>
> > > > > On 22 Jul., 21:28, Irving Ruan <irvingr...@gmail.com> wrote:
>
> > > > > > Hello,
>
> > > > > > Right now, I have my main web app displaying just fine on the page
> > > > > > when I run it through Eclipse GWT plugin.
>
> > > > > > When I navigate tohttp://127.0.0.1:8888/WebApp.html?gwt.codesvr=127.0.0.1:9997
> > > > > > I see my main page.
>
> > > > > > Now, I want to add an admin page where special users can edit stuff,
> > > > > > which basically necessitates that I need another page view. While I do
> > > > > > know how to create UIs, my problem is that I'm not sure how to
> > > > > > instantiate the page in my web.xml or WebApp.gwt.xml.
>
> > > > > > Here's what my web.xml contains:
>
> > > > > > <web-app>
>
> > > > > >    <!-- Servlets -->
> > > > > >   <servlet>
> > > > > >     <servlet-name>rpcServlet</servlet-name>
> > > > > >     <servlet-class>com.app.server.RPCCoreServiceImpl</servlet-class>
> > > > > >   </servlet>
>
> > > > > >   <servlet-mapping>
> > > > > >     <servlet-name>rpcServlet</servlet-name>
> > > > > >     <url-pattern>/webapp/rpcService</url-pattern>
> > > > > >   </servlet-mapping>
>
> > > > > >   <!-- Default page to serve -->
> > > > > >   <welcome-file-list>
> > > > > >     <welcome-file>WebApp.html</welcome-file>
> > > > > >   </welcome-file-list>
>
> > > > > > </web-app>
>
> > > > > > What would I need to change in my web.xml or WebApp.gwt.xml to be able
> > > > > > to instantiate a class, such as AdminPanel.java, as a page I can
> > > > > > navigate to and see? How would I be able to map that to my local URLhttp://127.0.0.1:8888/WebApp.html?gwt.codesvr=127.0.0.1:9997
>
> > > > > > Thanks in advance,
> > > > > > Irving

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment