The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

stefoid (8) [Avatar] Offline
#1
Hi. Chapter 4 pretty much assumes that data-binding method is the only way to go for a GWT app. At least it doesnt discuss any alternatives, nor the pros and cons.

Speaking for myself, Id like to see a more general discussion about GWT architeture choices, their pros and cons, before going into any one in detail.
charlie.collins (125) [Avatar] Offline
#2
Re: chapter 4 and general
Chapter 4 is meant to cover the "canonical" GWT data-binding/RPC example, in the intro "Part 1" of the book. In Part 2 (not yet on MEAP) we also cover things like JSON, SOAP (from the client, not only a server side proxy), and the various plain-old-XML (POX) methods using HttpRequest/RequestBuilder etc.

I think it is a fair point that we may need more discussion of architecture choices before getting into the canonical design, but we do also mention in a few places up to that point that other methods (aside from GWT RPC) are truly more about integration than green-field GWT architecture.

By "architecture" though, what sorts of things are you referring to, do you mean "Other Means to Communicate with Servers" (which we do have a chapter devoted to, not yet on MEAP) or do you mean more fundamental client side architectural patterns? (I just want to make sure I am in tune with exactly what you think needs more attention.)
stefoid (8) [Avatar] Offline
#3
Re: chapter 4 and general
Hi Charlie. chapter 4 that is available on the website covers the client side. data-bindng the model to the view.

cheers
charlie.collins (125) [Avatar] Offline
#4
Re: chapter 4 and general
That is now Chapter 5 (what is currently MEAPed as 4). MEAP will be updated soon I am sure.

Bigger question though, what other "architectures" would you like to see there, do you mean the other ways to communicate with servers or do you mean other GUI design patterns on the client?
nancy (1) [Avatar] Offline
#5
Re: chapter 4 and general
Hi:

How can i import and run chapter 4 in eclipse? Do you have any advise??
Thanks,
charlie.collins (125) [Avatar] Offline
#6
Re: chapter 4 and general
You would need to create an eclipse project and then copy in the code to run it in Eclipse. Chapter 4 is intentionally not an Eclipse related example (we were trying to show what's going on behind scenes, so you learn that, before we wanted to then also lean on an IDE).

The README describes how to run it outside of Eclipse though - http://gwt-in-practice.googlecode.com/svn/trunk/Ch4-CoreAppDesign/README-ch4.txt.
unclerico (3) [Avatar] Offline
#7
Re: chapter 4 and general
Charlie -

I'm having problems getting the source code up and running on my Windows machine.

1. I run the User-Compile-javac.cmd file (everything looks fine)

2. I run the User-shell.cmd file and the GWT broswer shell starts with no errors but the index.html page is blank. I get no errors in the shell logger except a warning that says [WARN] Loading the old 'gwt.js' bootstrap script is no longer supported; please load 'com.manning.gwtip.user.User.nocache.js' directly.

3. I have created a 'bookstore' database, and user with 'books' password in MySQL. I can log in to the database from the command prompt (it says something like, 'your connection number is 9')

To comply with the readme-ch4.txt, should I be 'logged' in to mysql via the command prompt? Or is it sufficient for the database and user profile to exist?

Do I need to change any other config settings to enable the MySQL connection? (Tell it which port SQL is running on or something?)

Any other ideas about why the index.html is blank?

Frustrating that there aren't any errors thrown to help figure it out.

Thanks in advance.
unclerico (3) [Avatar] Offline
#8
Re: chapter 4 and general
I did verify with the windows "sc query MySQL" command that the service is running, so I am at a loss.
charlie.collins (125) [Avatar] Offline
#9
Re: chapter 4 and general
I believe the problem you have is simply our fault, as it looks like that chapter did NOT get upgraded for GWT 1.4/1.5 in terms of using the module "nocache" to load from the host page rather than gwt.js.

Long story, but GWT before 1.4 used a different means of loading from the host page. We began writing the book in the 1.3/1.4 RC days, and ended with 1.4.60 and some peeks at 1.5 stuff (but no official 1.5 release). In GWT 1.4 the gwt.js stuff was deprecated, but *still worked* (meaning chapter 4 works fine if you are using GWT 1.4.x), in GWT 1.5 it no longer works.

The GWT docs put it this way:
"The gwt.js bootstrap file has been deprecated since 1.4 in favor of the <module>.nocache.js bootstrap file, and is no longer generated in 1.5. If your application host HTML page bootstraps using the gwt.js file, now is the time to make the change to the new <module>.nocache.js file. "

In most of our chapters, we knew this change was coming, and changed our host pages. For example, chapter 2 looks like:
http://gwt-in-practice.googlecode.com/svn/trunk/Ch2-NewClient/src/com/manning/gwtip/calculator/public/Calculator.html

But chapter 4 we must have missed, because it still uses the gwt.js way, as such:
http://gwt-in-practice.googlecode.com/svn/trunk/Ch4-CoreAppDesign/src/com/manning/gwtip/user/public/index.html

*TO FIX CHAPTER 4 EXAMPLE FOR GWT 1.5*:
Replate the host page (index.html in public folder) gwt.js line (<script language='javascript' src='gwt.js'></script>smilie with the following:

<script language="javascript" src="com.manning.gwtip.user.User.nocache.js"></script>

Also, the meta tag line from the top of the host file can be removed (won't cause any errors if you leave it, but it's not needed anymore).

Sorry about that, and hope the explanation helps.
charlie.collins (125) [Avatar] Offline
#10
Re: chapter 4 and general
And one other note there, you don't have to be logged in to MySQL, nope. The database just has to exist, and MySQL server has to be running locally, the JPA stuff will create the tables, the app will use them, but the DB has to be there as a pre-req.
unclerico (3) [Avatar] Offline
#11
Re: chapter 4 and general
Thanks Charlie - I altered my index.html file as described and am a step closer.

Now I am getting a different error. I compile, then run the shell and fail to load. The shell says:


ERROR] Failure to load module 'com.manning.gwtip.user.User'
java.lang.NullPointerException: null
at com.google.gwt.core.ext.typeinfo.JRealClassType.setSuperclass(JRealClassType.java:395)
at com.google.gwt.dev.javac.TypeOracleMediator.resolveTypeDeclaration(TypeOracleMediator.java:1397)
at com.google.gwt.dev.javac.TypeOracleMediator.refresh(TypeOracleMediator.java:382)
at com.google.gwt.dev.javac.CompilationState.compile(CompilationState.java:137)
at com.google.gwt.dev.cfg.ModuleDef.updateTypeOracle(ModuleDef.java:477)
at com.google.gwt.dev.cfg.ModuleDef.getTypeOracle(ModuleDef.java:324)
at com.google.gwt.dev.GWTShell$BrowserWidgetHostImpl.createModuleSpaceHost(GWTShell.java:252)
at com.google.gwt.dev.shell.ie.BrowserWidgetIE6$External.gwtOnLoad(BrowserWidgetIE6.java:72)
at com.google.gwt.dev.shell.ie.BrowserWidgetIE6$External.invoke(BrowserWidgetIE6.java:139)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:720)
at com.google.gwt.dev.GWTShell.run(GWTShell.java:593)
at com.google.gwt.dev.GWTShell.main(GWTShell.java:357)
charlie.collins (125) [Avatar] Offline
#12
Re: chapter 4 and general
I haven't seen that one.

I will try to find some time in the next few days though to load the chapter 4 stuff using GWT 1.5.3 and see if I can figure it out.

As a workaround in the meantime, assuming you aren't already using GWT 1.4.60 (I guess I should ask that specifically - which GWT are you using), you might try that (it's a step back from the current release, yes, but it's what these examples were written and tested on).