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.