diff --git a/.settings/com.google.gdt.eclipse.core.prefs b/.settings/com.google.gdt.eclipse.core.prefs index cc6cb35..11a59ec 100644 --- a/.settings/com.google.gdt.eclipse.core.prefs +++ b/.settings/com.google.gdt.eclipse.core.prefs @@ -1,3 +1,4 @@ eclipse.preferences.version=1 +jarsExcludedFromWebInfLib= warSrcDir=war warSrcDirIsOutput=true diff --git a/.settings/com.google.gwt.eclipse.core.prefs b/.settings/com.google.gwt.eclipse.core.prefs index 077314c..8aece0e 100644 --- a/.settings/com.google.gwt.eclipse.core.prefs +++ b/.settings/com.google.gwt.eclipse.core.prefs @@ -1,2 +1,3 @@ eclipse.preferences.version=1 filesCopiedToWebInfLib=gwt-servlet.jar +gwtCompileSettings=PGd3dC1jb21waWxlLXNldHRpbmdzPjxsb2ctbGV2ZWw+SU5GTzwvbG9nLWxldmVsPjxvdXRwdXQtc3R5bGU+T0JGVVNDQVRFRDwvb3V0cHV0LXN0eWxlPjxleHRyYS1hcmdzPjwhW0NEQVRBW11dPjwvZXh0cmEtYXJncz48dm0tYXJncz48IVtDREFUQVstWG14NTEybV1dPjwvdm0tYXJncz48ZW50cnktcG9pbnQtbW9kdWxlPm5ldC5tb2xlei5tYW5kbG0uZm90b3N0cmVhbS5Gb3RvU3RyZWFtPC9lbnRyeS1wb2ludC1tb2R1bGU+PC9nd3QtY29tcGlsZS1zZXR0aW5ncz4\= diff --git a/src/net/molez/mandlm/fotostream/client/CurrentImageURLService.java b/src/net/molez/mandlm/fotostream/client/CurrentImageURLService.java new file mode 100644 index 0000000..f4e1c2e --- /dev/null +++ b/src/net/molez/mandlm/fotostream/client/CurrentImageURLService.java @@ -0,0 +1,10 @@ +package net.molez.mandlm.fotostream.client; + +import com.google.gwt.user.client.rpc.RemoteService; +import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; + +@RemoteServiceRelativePath("currentImageURL") +public interface CurrentImageURLService extends RemoteService +{ + String getCurrentImageURL(); +} diff --git a/src/net/molez/mandlm/fotostream/client/CurrentImageURLServiceAsync.java b/src/net/molez/mandlm/fotostream/client/CurrentImageURLServiceAsync.java new file mode 100644 index 0000000..65e6f91 --- /dev/null +++ b/src/net/molez/mandlm/fotostream/client/CurrentImageURLServiceAsync.java @@ -0,0 +1,8 @@ +package net.molez.mandlm.fotostream.client; + +import com.google.gwt.user.client.rpc.AsyncCallback; + +public interface CurrentImageURLServiceAsync +{ + void getCurrentImageURL(AsyncCallback callback); +} diff --git a/src/net/molez/mandlm/fotostream/client/FotoStream.java b/src/net/molez/mandlm/fotostream/client/FotoStream.java index 2bc237e..536e659 100644 --- a/src/net/molez/mandlm/fotostream/client/FotoStream.java +++ b/src/net/molez/mandlm/fotostream/client/FotoStream.java @@ -8,10 +8,13 @@ import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyUpEvent; import com.google.gwt.event.dom.client.KeyUpHandler; +import com.google.gwt.event.dom.client.LoadEvent; +import com.google.gwt.event.dom.client.LoadHandler; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.DialogBox; import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.TextBox; @@ -32,6 +35,7 @@ public class FotoStream implements EntryPoint { * Create a remote service proxy to talk to the server-side Greeting service. */ private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class); + private final CurrentImageURLServiceAsync imageURLService = GWT.create(CurrentImageURLService.class); /** * This is the entry point method. @@ -41,15 +45,47 @@ public class FotoStream implements EntryPoint { final TextBox nameField = new TextBox(); nameField.setText("GWT User"); final Label errorLabel = new Label(); + + final Image image = new Image(); + image.setVisible(false); + image.addLoadHandler(new LoadHandler() + { + @Override + public void onLoad(LoadEvent event) + { + image.setVisible(true); + image.setWidth("100%"); + } + }); + + imageURLService.getCurrentImageURL(new AsyncCallback() + { + @Override + public void onFailure(Throwable caught) + { + DialogBox errorMsg = new DialogBox(); + + errorMsg.setTitle("Error loading current immage"); + errorMsg.setHTML(caught.getMessage()); + errorMsg.show(); + } + + @Override + public void onSuccess(String result) + { + image.setUrl(result); + } + }); // We can add style names to widgets - sendButton.addStyleName("sendButton"); + sendButton.addStyleName("sendButton"); // Add the nameField and sendButton to the RootPanel // Use RootPanel.get() to get the entire body element RootPanel.get("nameFieldContainer").add(nameField); RootPanel.get("sendButtonContainer").add(sendButton); RootPanel.get("errorLabelContainer").add(errorLabel); + RootPanel.get("imageContainer").add(image); // Focus the cursor on the name field when the app loads nameField.setFocus(true); diff --git a/src/net/molez/mandlm/fotostream/server/CurrentImageURLServiceImpl.java b/src/net/molez/mandlm/fotostream/server/CurrentImageURLServiceImpl.java new file mode 100644 index 0000000..3b5a2b3 --- /dev/null +++ b/src/net/molez/mandlm/fotostream/server/CurrentImageURLServiceImpl.java @@ -0,0 +1,14 @@ +package net.molez.mandlm.fotostream.server; + +import com.google.gwt.user.server.rpc.RemoteServiceServlet; + +import net.molez.mandlm.fotostream.client.CurrentImageURLService; + +@SuppressWarnings("serial") +public class CurrentImageURLServiceImpl extends RemoteServiceServlet implements CurrentImageURLService +{ + public String getCurrentImageURL() + { + return "img/dummy.jpg"; + } +} diff --git a/war/FotoStream.html b/war/FotoStream.html index 3924eba..2b610af 100644 --- a/war/FotoStream.html +++ b/war/FotoStream.html @@ -57,6 +57,9 @@ + + + diff --git a/war/WEB-INF/web.xml b/war/WEB-INF/web.xml index 1cc5293..2cd57fe 100644 --- a/war/WEB-INF/web.xml +++ b/war/WEB-INF/web.xml @@ -16,6 +16,16 @@ /fotostream/greet + + currentImageURLServlet + net.molez.mandlm.fotostream.server.CurrentImageURLServiceImpl + + + + currentImageURLServlet + /fotostream/currentImageURL + + FotoStream.html diff --git a/war/img/dummy.jpg b/war/img/dummy.jpg new file mode 100644 index 0000000..1963596 Binary files /dev/null and b/war/img/dummy.jpg differ