I've developed applications with PHP throwing out the html pages to the client. But I've been trying out the GWT-PHP/JSON combination, and it's a whole lot faster in my experience. The client just calls a single GWT application, and everything within are just async callbacks to a PHP page that throws back JSON formatted data.
I haven't tested out its improved efficiency, because so far, these new applications were just for in-house lab use. On Jun 25, 5:09 am, Ben Harris <bharri...@gmail.com> wrote: > That is a better solution, but they might not want the extra round > trip time of requesting the data after the page has been sent down the > wire. > > On Jun 25, 5:04 pm, Chris Boertien <chris.boert...@gmail.com> wrote: > > > > > You might want to take a look at > > this:http://code.google.com/webtoolkit/doc/latest/tutorial/JSON.html > > > Although the examples there are using a servlet for the server-side, > > that is not a requirement. The server simply needs to be accessible at > > the requested URL and output the formatted JSON. > > > The basic idea is to make a request to the server and have the server > > send back the json data structure. You can then eval, or use a js json > > parser, and setup Overlay types so you get to use the objects like > > regular java objects. > > > 2010/6/24 Jaroslav Záruba <jaroslav.zar...@gmail.com>: > > > > I believe the module loads on document's load event, therefore pausing PHP > > > does not help indeed. > > > You can load the JSON using JsonpRequestBuilder. That means another > > > (XHR)request to server. If that's an issue I'd try to output the JSON > > > using > > > PHP as you do now, but not into <script/> element. I would hide it within > > > the page and afterwards convert that JSON-string into a JS-object in GWT. > > > Or you could place the JSON-string into a <script/> element using GWT, > > > tthat > > > should fire the addTreeItems-method right away. > > > When I needed to load some data from (3rd-party) server I created my > > > receiving JS-function and the <script/> element with src-attribute by > > > myself > > > in onModuleLoad. It worked. And I guess that's similar to what the > > > JsonpRequestBuilder does, but I did not know that class before. I'm quite > > > new to GWT. > > > That's also kind of disclaimer: I'm not sure whether the above is the best > > > and most elegant solution. :) > > > On Fri, Jun 25, 2010 at 3:25 AM, barbe...@muohio.edu <barbe...@muohio.edu> > > > wrote: > > > >> Thanks, that makes sense. However, do you have any suggestions on how > > >> I might work around it? I want to be able to load all of the data on > > >> startup, so I have called the PHP function that calls the javascript > > >> function in the <body> of the .php file. I tried to throw in a PHP > > >> sleep to delay the javascript from being called, but the sleep seems > > >> to also delay the loading of the module, thus really giving me no > > >> benefit. Any other suggestions would be great. > > > >> On Jun 24, 8:47 pm, Jaroslav Záruba <jaroslav.zar...@gmail.com> wrote: > > >> > It seems that your <script/> might get evaluated/executed before the > > >> > module > > >> > has finished loading and therefore your function window.addTreeItem > > >> > might > > >> > not exist yet. > > >> > Several workarounds for that are possible I think. > > > >> > On Thu, Jun 24, 2010 at 9:39 PM, barbe...@muohio.edu > > >> > <barbe...@muohio.edu>wrote: > > > >> > > Hi everyone, > > > >> > > I am faced with a situation in which I must pass variables read in > > >> > > from a database table using PHP to my GWT application. I am doing > > >> > > this > > >> > > by using PHP to read in the data(which are Strings), and then calling > > >> > > a JSNI function from my GWT application like so: > > > >> > > $result = mysql_query("SELECT * FROM sampleTreeTable"); > > > >> > > while($row = mysql_fetch_array($result)) { > > >> > > $temp = $row['treeItem']; > > >> > > echo "<script language=javascript>addTreeItems('$temp');</ > > >> > > script>"; > > >> > > } > > > >> > > I know that my echo statement works, because when I call other > > >> > > locally > > >> > > defined javascript functions in the place of addTreeItems, they > > >> > > execute just fine. It is only the JSNI function addTreeItems that > > >> > > does > > >> > > not seem to execute. > > > >> > > The function addTreeItems is defined in the Java source code for my > > >> > > GWT application as follows: > > > >> > > public void serverAdd(String s) { > > >> > > //some code > > >> > > } > > > >> > > public native void setShowTrigger(TreeTest x)/*-{ > > > >> > > $wnd.addTreeItem = function(s) { > > > >> > > x...@com.treetest.tomproject.client.treetest::serverAdd(Ljava/lang/ > > >> > > String;)(s); > > > >> > > }; > > >> > > }-*/; > > > >> > > When running my GWT application in development mode, accessing > > >> > > addTreeItems through the html file works just fine, most of the time > > >> > > anyways. Sometimes when I first start debugging it will not execute, > > >> > > but if I refresh the page it always executes just fine. > > >> > > The real problem occurs once I compile my application and deploy it > > >> > > to > > >> > > my web server. I seem to be unable to call addTreeItems once my > > >> > > application is deployed. Once I deploy my GWT generated html file, I > > >> > > change the file from a .html to a .php file so that I can add the PHP > > >> > > code, and everything still works just fine except my JSNI > > >> > > addTreeItems > > >> > > method. > > > >> > > So basically, I am completely lost on this issue. Anyone have any > > >> > > idea > > >> > > how to accomplish what I am trying to do? I know I could use RPC to > > >> > > connect to the database and do most all of this within my GWT > > >> > > application, but the requirements of this project stipulate that I > > >> > > avoid doing so. Any help at all would be great. > > > >> > > -- > > >> > > 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-tool...@googlegroups.com. > > >> > > To unsubscribe from this group, send email to > > > >> > > google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2Bunsubs > > >> > > cr...@googlegroups.com> > > >> > > . > > >> > > For more options, visit this group at > > >> > >http://groups.google.com/group/google-web-toolkit?hl=en. > > > >> -- > > >> 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-tool...@googlegroups.com. > > >> To unsubscribe from this group, send email to > > >> google-web-toolkit+unsubscr...@googlegroups.com. > > >> For more options, visit this group at > > >>http://groups.google.com/group/google-web-toolkit?hl=en. > > > > -- > > > 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-tool...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > google-web-toolkit+unsubscr...@googlegroups.com. > > > For more options, visit this group at > > >http://groups.google.com/group/google-web-toolkit?hl=en. -- 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-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.