January 15th, 2007
Accessing PHP pages for debugging in hosted mode has been an issue mostly confined to those running Linux systems prior to IE7. Now the question comes up for Windows developers as well. I never liked the Tomcat proxy idea since it lends itself to writing code using GWT.isScript(), which I would rather avoid. I like to write code that is identical in testing to its final deployed form. So I wanted to find another solution.
Read the rest of this entry »
Posted in Google Web Toolkit | 2 Comments »
November 28th, 2006
I am starting a new project using GWT for the client side again. This is exciting because I will use it as an excuse to update the tutorials for the new 1.2 version of the toolkit. I’m looking forward to seeing what improvements I can make with the new features, especially the http features. From what I read in the docs, there should be some great potential there.
For an adventure, I’m writing from my new blackberry. Good times. Hooray for quarter VGA. I still need to get my internet access sorted out but this is far better than nothing at all.
Posted in Google Web Toolkit | Comments Off
September 27th, 2006
I got to wondering if it would be possible to add PHP to the output of the web tookit compiler. In short, the answer is yes. I’ll have to play around with it some more to see what code ends up in cached files and what code goes to nocache files, since that would be rather important.
I tried adding a PHP block to JSNI code. Oddly enough, the compiler complains about the bad syntax. Which is fine since it is bad javascript syntax, to some extent… If nothing else, it’s an inappropriate place for random HTML tags. The compiler will not complain, though, if you stick the code into an HTML comment. But comments get stripped out during obfuscation, so this doesn’t matter.
Read the rest of this entry »
Posted in Google Web Toolkit | 2 Comments »
September 24th, 2006
I have seen several searches looking for information on hashmaps within the Google Web Toolkit. As part of the ‘String-based RPC’ sample code (found here), I use hashmaps to store pending requests. If a call to HTTPRequest.AsyncPost fails (i.e. returns false, a condition which I have never seen and from what I recall from looking through the JAR, won’t happen), the code iterates over the hashmap to call the onFailure methods of the RPC’d objects. ServerComm.java has the loop about two-thirds of the way down. It takes a bit of casting to make it happen.
Specifically, it is:
for (Iterator i=waitingReqs.entrySet().iterator(); i.hasNext(); ) {
((ServerData)((Map.Entry)i.next()).getValue()).onFailure(”Call failed”);
}
where waitingReqs is a HashMap. To get an iterator, you first need to get the entrySet for the HashMap. This is a set containing key/value pairs as Map.Entry objects. The Iterator returns a specific Map.Entry. I only need the value, since in this case the key is unimportant.
As a further note, there should probably be @gwt.TypeArgs definitions for the HashMap variables specifying the data types stored within the HashMap. It works without them, but it would be better form to include them.
Posted in Google Web Toolkit | Comments Off
September 14th, 2006
I’ve posted a new tutorial here documenting a string-based approach to an RPC mechanism. This is not the ‘real’ GWT wire protocol. Rather it is a stronger and more convenient method extended from the previous tutorials. If you are passing form data between a PHP server and a GWT client, this may help simplify your life.
Posted in Google Web Toolkit | 2 Comments »
September 2nd, 2006
This was a little trick that I finally found. I have a template page with a left-column navigation bar. I wanted to add a feedback function to this nav bar. This got me to the question of what the RootPanel is and what needs to happen to add functionality.
I figured that widgets are ultimately DOM items, so I inserted the widget element at the top of the column. This almost worked: my widget showed up where I wanted it, but it didn’t do anything. It turns out that you need to add it to the RootPanel first, then move it’s element to the desired location in the DOM.
In the onModuleLoad function, I have:
public void onModuleLoad() {
final String idStr = “LeftCol”;
Element leftCol = DOM.getElementById(idStr);
final Label link = new Label(”Not finding what you want?”);
RootPanel.get().add(link);
DOM.insertChild(leftCol, link.getElement(), 0);
link.addClickListener( new ClickListener() {
public void onClick(Widget w) {
PopupPanel pu = new MyPopup();
pu.setPopupPosition(link.getAbsoluteLeft(), link.getAbsoluteTop());
pu.show();
}
});
}
This also provides a popup window which relocates itself to the top left corner of the Label. The popup code was taken directly from the example code in the Google documentation of PopupPanel.
I don’t know exactly what happens when widgets are added to the RootPanel, but this technique does allow for proper positioning and functionality of the widget when it is added to an existing part of the DOM structure.
Posted in Google Web Toolkit | Comments Off
August 30th, 2006
I am involved with several sites that work very well with AdSense. At this point, these are sites that are strictly HTML, with no dynamic content whatsoever (purely content). The question I have been asking myself is whether I can use GWT to possibly improve my AdSense performance.
I have seen a few questions about how one might add AdSense to AJAX or GWT websites. Is this question asked backwards? Should it really be how to add GWT to AdSense sites?
Read the rest of this entry »
Posted in Google Web Toolkit | 2 Comments »
August 25th, 2006
I have found the regular expression support in GWT (if not JavaScript in general) to be more limited than what I am used to from PHP. This is fine — it’s powerful enough for most form validation, and a nice tool to use for simple parsing. But there are times when that’s just not enough. In working on my RPC code, I had a head-slapping moment when I realized that it was just as easy to provide access to PHP functions like preg_match via RPC.
It certainly can simplify those situation where you just need to validate something significant. You can probably also get more regex power through JSNI, but I like sticking to higher level functionality. I’d no doubt program in a memory leak or some other irritating feature that would be painful to debug.
Posted in Google Web Toolkit | Comments Off
August 14th, 2006
I was having some difficulty finding exact details about support for url encoding in javascript/GWT. The most correct method for matching urlencode is to use encodeURIComponent. I can’t find the exact link again, but one source said that support for encodeURIComponent was unreliable across JavaScript implementations. Another reference compared escape, encodeURI and encodeURIComponent and their documentation suggested that it should be quite common by now.
Read the rest of this entry »
Posted in Google Web Toolkit | Comments Off
August 4th, 2006
I’m working on the finishing touches of another tutorial article for PHP / GWT. Sticking with a simple and superficial approach, it is largely an extension of the previous tutorials. It won’t totally replace the mechanism in GWT, but since that’s not easily available to PHP developers (yet), it is useful. Plus it makes for a simplified demonstration of how more complicated interactions might be structured.
I hope to get it written up and posted in the next couple of days. I still need to implement some sample functions in PHP. As of today, the code is working on the client side, but the server side doesn’t do anything interesting.
Posted in Google Web Toolkit | Comments Off