Dummy getCurrentImageURL Servive
This commit is contained in:
parent
13011b536a
commit
eb0cf257ca
9 changed files with 84 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
|||
eclipse.preferences.version=1
|
||||
jarsExcludedFromWebInfLib=
|
||||
warSrcDir=war
|
||||
warSrcDirIsOutput=true
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
eclipse.preferences.version=1
|
||||
filesCopiedToWebInfLib=gwt-servlet.jar
|
||||
gwtCompileSettings=PGd3dC1jb21waWxlLXNldHRpbmdzPjxsb2ctbGV2ZWw+SU5GTzwvbG9nLWxldmVsPjxvdXRwdXQtc3R5bGU+T0JGVVNDQVRFRDwvb3V0cHV0LXN0eWxlPjxleHRyYS1hcmdzPjwhW0NEQVRBW11dPjwvZXh0cmEtYXJncz48dm0tYXJncz48IVtDREFUQVstWG14NTEybV1dPjwvdm0tYXJncz48ZW50cnktcG9pbnQtbW9kdWxlPm5ldC5tb2xlei5tYW5kbG0uZm90b3N0cmVhbS5Gb3RvU3RyZWFtPC9lbnRyeS1wb2ludC1tb2R1bGU+PC9nd3QtY29tcGlsZS1zZXR0aW5ncz4\=
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package net.molez.mandlm.fotostream.client;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
public interface CurrentImageURLServiceAsync
|
||||
{
|
||||
void getCurrentImageURL(AsyncCallback<String> callback);
|
||||
}
|
|
@ -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<String>()
|
||||
{
|
||||
@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);
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
|
@ -57,6 +57,9 @@
|
|||
<tr>
|
||||
<td colspan="2" style="color:red;" id="errorLabelContainer"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" id="imageContainer"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -16,6 +16,16 @@
|
|||
<url-pattern>/fotostream/greet</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>currentImageURLServlet</servlet-name>
|
||||
<servlet-class>net.molez.mandlm.fotostream.server.CurrentImageURLServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>currentImageURLServlet</servlet-name>
|
||||
<url-pattern>/fotostream/currentImageURL</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- Default page to serve -->
|
||||
<welcome-file-list>
|
||||
<welcome-file>FotoStream.html</welcome-file>
|
||||
|
|
BIN
war/img/dummy.jpg
Normal file
BIN
war/img/dummy.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 733 KiB |
Loading…
Reference in a new issue