Hi again,

sry but this afternoon, I didn´t have much time. So some want to know,
what I did, and how it works. Ok so you want it ... you get it. :-)

Ok as said before, I wanted a MVP-Framework based dynamically
Module/Transaction/UI App. It´s just like ... 2 Menu Panels and
one Content Panel. Imagine, you have a small bar on top and one on the
bottom of a webpage. Between are the dynamically loaded Modules.

So I implemented a "main"-MVP-App, in which App-Controller, all
Presenters of the Views are controlled. So, the point is, if a user
wants
to do some action, then the "content panel" should change.

Ok, no problem to ths point. But the App seems to become very very
large,
for many many users. .. I hope so :) ....

So the point is, I don´t want to have all Views, Presenters, Event-
Handlers etc.
in one GWT-Eclipse-Project. So every "module/UI/transaction" are
single
stnadalone Java-Projects, on my workspace. Just include every
Projects
.gwt.xml you want to use, and extract .jars and include them in the /
war/WEB-INF/lib
directory, for the server-side code.

Ok, so to the problem I had. I want to dynamically load the content
"module".
I just have to say, that not every user can load every module. So I
have something
like rights-profiles. So I implemented a few "jdo-classes", which save
the "modules"
and the user-profiles, and also!! the class, which starts to load the
"modules".

It´s a little late, so I hope it´s clear, what I´m saying..... :-)

OK, so I made a service, which gets the name of the moduels-class as a
string.
This service is called, when a user want to perform some transaction
(load a module).
Then I uses java.lang.reflect.... to get the class. Now I instanciate
the class, as a
instance of an interface (see posts above) and return it to the
client. So now I can
call the method start() on the client, and the desired UI is loading.

The problrm I had was, that I got anoying ClassCastErrors, on the
server, so it didn´t work.
I did it like this:

MyInterface obj = (MyInterface)
Class.forName(string_of_classname).newInstance();

but this doesn´t work. I found a solution, of avoiding this error by
doing this like this:

Constructor myContructor =
Class,forName(string_of_classname).getDeclaredConstructor();
MyInterface obj = (MyInterface) myContructor.newInstance();

This is working, seems like AppEngine had a problem, using the
standard constructor,
don´t know why, but now it´s working.

I hope this answers all yor questons??

Greets Alex



On 16 Aug., 20:16, Rogério Valente <[email protected]> wrote:
> Hi Alex,
>
> How about post the solution here for the entire group? :-)
>
> On 16 ago, 11:12, AlexG <[email protected]> wrote:
>
> > Hi again,
>
> > I solved the problem, and now it works, as intended :)
> > If somebody has any questions, how this works, just
> > eMail me.
>
> > Greets
> > Alex
>
> > On 16 Aug., 15:37, AlexG <[email protected]> wrote:
>
> > > Hi,
>
> > > first thanks for your fast reply.
> > > I think this should work. Perhaps I should just
> > > give more background information.
>
> > > The App is build using the MVP Pattern. I have one
> > > "main"-Page, with 3 Panels (3 div-elements in the .html)
>
> > > Two of the three panels will never change during runtime. These
> > > contains the menu control-widgets. If i select something,
> > > then the "content"-Panel should load the requestet UI (Module).
>
> > > This means, it should load just a new MVP-View via a new MVP
> > > presenter.
> > > The views and presenters are seperated in extra Projects in Eclipse,
> > > just
> > > to make it easy to maintain the App.
>
> > > So I definitely don´t want anything in one Project, or any widget in
> > > one onModuleLoad(). I also don´t want lots of if´s to decide, which
> > > view should be shown, because the app must be highly maintainable,
> > > reusable
> > > and extensable.
>
> > > By-the-way, the way I do it, works, if I code it with many if´s. But I
> > > think
> > > this is a "dirty" solution, and not what I want.
>
> > > Thanks, for your suggestions anyway. Maybe you got asnother idea??
>
> > > Thanks.
>
> > > Greets Alex
>
> > > On 16 Aug., 14:49, André Moraes <[email protected]> wrote:
>
> > > > This aproach will not work, since after compiled GWT generates pure
> > > > JavaScript.
>
> > > > You could do the following:
>
> > > > 1- Create an JSP page (index.jsp) and use this page as your GWT hosted 
> > > > page.
> > > > 2- When rendering the page, check the name of the module (not the name 
> > > > of
> > > > the class) that you want to load.
> > > > 3- Create one Module.gwt.xml file for each of the user interface that 
> > > > you
> > > > want to load.
> > > > 4- When renderinhg the script tag that loads your selection script, 
> > > > change
> > > > the name of your selection script based on the information that you
> > > > retreived from the datastore.
>
> > > > This options generate lots of files in your GAE application, because 
> > > > each UI
> > > > will be compiled independ of another, but its fast.
>
> > > > Another option will be:
>
> > > > 1- Write your GWT application with all the UI and only one entry point
> > > > class.
> > > > 2- Create an jsp and define a cookie with the name (not the classname, 
> > > > GWT
> > > > doesn't have reflection) of the UI that you want to load.
> > > > 3- Inside your onModuleLoad function, write a series of if's that will 
> > > > check
> > > > this cookie and load the UI that you want.
> > > > 4- Use the GWT.async (code-splitting) to load the UI that you want, this
> > > > will cost another round-trip but will download much less code. If you 
> > > > don't
> > > > do that, the browser will download all the code for all the UI.
>
> > > > Hope it helps.
>
> > > > --
> > > > André Moraes
> > > > Analista de Desenvolvimento de Sistemas
> > > > [email protected]http://andredevchannel.blogspot.com/

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

Reply via email to