Init non working version
BIN
TestGWT/.DS_Store
vendored
Normal file
8
TestGWT/.classpath
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="src" output="test-classes" path="test"/>
|
||||||
|
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
<classpathentry kind="output" path="war/WEB-INF/classes"/>
|
||||||
|
</classpath>
|
||||||
34
TestGWT/.project
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>TestGWT</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>com.google.gwt.eclipse.core.gwtNature</nature>
|
||||||
|
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
3
TestGWT/.settings/com.google.gdt.eclipse.core.prefs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
warSrcDir=war
|
||||||
|
warSrcDirIsOutput=true
|
||||||
2
TestGWT/.settings/com.google.gwt.eclipse.core.prefs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
filesCopiedToWebInfLib=gwt-servlet.jar
|
||||||
12
TestGWT/.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.8
|
||||||
2
TestGWT/.settings/org.eclipse.ltk.core.refactoring.prefs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<faceted-project>
|
||||||
|
<installed facet="java" version="1.8"/>
|
||||||
|
</faceted-project>
|
||||||
BIN
TestGWT/src/.DS_Store
vendored
Normal file
BIN
TestGWT/src/com/.DS_Store
vendored
Normal file
BIN
TestGWT/src/com/test/.DS_Store
vendored
Normal file
BIN
TestGWT/src/com/test/gwt/.DS_Store
vendored
Normal file
42
TestGWT/src/com/test/gwt/TestGWT.gwt.xml
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
When updating your version of GWT, you should also update this DTD reference,
|
||||||
|
so that your app can take advantage of the latest GWT module capabilities.
|
||||||
|
-->
|
||||||
|
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.7.0//EN"
|
||||||
|
"http://gwtproject.org/doctype/2.7.0/gwt-module.dtd">
|
||||||
|
<module rename-to='testgwt'>
|
||||||
|
<!-- Inherit the core Web Toolkit stuff. -->
|
||||||
|
<inherits name='com.google.gwt.user.User'/>
|
||||||
|
|
||||||
|
<!-- Inherit the default GWT style sheet. You can change -->
|
||||||
|
<!-- the theme of your GWT application by uncommenting -->
|
||||||
|
<!-- any one of the following lines. -->
|
||||||
|
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
|
||||||
|
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
|
||||||
|
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
|
||||||
|
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
|
||||||
|
|
||||||
|
|
||||||
|
<inherits name="com.google.gwt.resources.Resources" />
|
||||||
|
<inherits name="gwt.react.React" />
|
||||||
|
<inherits name="gwt.redux.Redux" />
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Other module inherits -->
|
||||||
|
<!-- Specify the app entry point class. -->
|
||||||
|
<entry-point class='com.test.gwt.client.TestGWT'/>
|
||||||
|
|
||||||
|
<!-- Specify the paths for translatable code -->
|
||||||
|
<source path='client'/>
|
||||||
|
|
||||||
|
|
||||||
|
<set-configuration-property name="CssResource.style" value="pretty" />
|
||||||
|
<set-configuration-property name="CssResource.obfuscationPrefix" value="empty" />
|
||||||
|
|
||||||
|
<!-- allow Super Dev Mode -->
|
||||||
|
<add-linker name="xsiframe"/>
|
||||||
|
<set-configuration-property name="devModeRedirectEnabled" value="true"/>
|
||||||
|
<set-property name="compiler.useSourceMaps" value="true" />
|
||||||
|
|
||||||
|
</module>
|
||||||
19
TestGWT/src/com/test/gwt/client/GWTReactBundleWrapper.java
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package com.test.gwt.client;
|
||||||
|
|
||||||
|
import com.google.gwt.core.client.ScriptInjector;
|
||||||
|
import com.test.gwt.client.TestGWT.JsClientBundle;
|
||||||
|
|
||||||
|
public class GWTReactBundleWrapper {
|
||||||
|
public static void injectScript() {
|
||||||
|
if (!isInjected()) {
|
||||||
|
ScriptInjector.fromString(JsClientBundle.INSTANCE.gwtreactbundlejs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private native final static boolean isInjected() /*-{
|
||||||
|
if (!(typeof $wnd.TestGWT === "undefined") && !(null===$wnd.TestGWT)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}-*/;
|
||||||
|
}
|
||||||
14
TestGWT/src/com/test/gwt/client/LoginService.java
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package com.test.gwt.client;
|
||||||
|
import com.google.gwt.user.client.rpc.RemoteService;
|
||||||
|
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||||
|
import com.test.gwt.shared.UserDTO;
|
||||||
|
|
||||||
|
@RemoteServiceRelativePath("login")
|
||||||
|
public interface LoginService extends RemoteService
|
||||||
|
{
|
||||||
|
UserDTO loginServer(String name, String password);
|
||||||
|
|
||||||
|
UserDTO loginFromSessionServer();
|
||||||
|
|
||||||
|
void logout();
|
||||||
|
}
|
||||||
13
TestGWT/src/com/test/gwt/client/LoginServiceAsync.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package com.test.gwt.client;
|
||||||
|
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.test.gwt.shared.UserDTO;
|
||||||
|
|
||||||
|
public interface LoginServiceAsync
|
||||||
|
{
|
||||||
|
void loginServer(String name, String password, AsyncCallback<UserDTO> callback);
|
||||||
|
|
||||||
|
void loginFromSessionServer(AsyncCallback<UserDTO> callback);
|
||||||
|
|
||||||
|
void logout(AsyncCallback<Void> callback);
|
||||||
|
}
|
||||||
235
TestGWT/src/com/test/gwt/client/TestGWT.java
Normal file
@@ -0,0 +1,235 @@
|
|||||||
|
package com.test.gwt.client;
|
||||||
|
|
||||||
|
import com.test.gwt.shared.UserDTO;
|
||||||
|
|
||||||
|
import jdk.management.resource.internal.inst.WindowsAsynchronousFileChannelImplRMHooks;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.google.gwt.core.client.EntryPoint;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.core.client.ScriptInjector;
|
||||||
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
|
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.resources.client.ClientBundle;
|
||||||
|
import com.google.gwt.resources.client.TextResource;
|
||||||
|
import com.google.gwt.user.client.Cookies;
|
||||||
|
import com.google.gwt.user.client.Window;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.gwt.user.client.ui.Button;
|
||||||
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
|
import com.google.gwt.user.client.ui.Label;
|
||||||
|
import com.google.gwt.user.client.ui.RootPanel;
|
||||||
|
import com.google.gwt.user.client.ui.TextBox;
|
||||||
|
import com.google.gwt.user.client.ui.PasswordTextBox;
|
||||||
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
import gwt,react.client.api.GwtReact;
|
||||||
|
import gwt.react.client.api.React;
|
||||||
|
import gwt.react.client.api.ReactDOM;
|
||||||
|
import gwt.react.client.components.ClassicComponentClass;
|
||||||
|
import gwt.react.client.events.MouseEventHandler;
|
||||||
|
import gwt.react.client.proptypes.BaseProps;
|
||||||
|
import gwt.react.client.utils.ObjLiteral;
|
||||||
|
import gwt.react_examples.redux.counter.client.components.Counter;
|
||||||
|
import gwt.react_examples.redux.counter.client.reducers.CounterReducer;
|
||||||
|
import gwt.redux.client.Action;
|
||||||
|
import gwt.redux.client.Redux;
|
||||||
|
import gwt.redux.client.Store;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entry point classes define <code>onModuleLoad()</code>.
|
||||||
|
*/
|
||||||
|
public class TestGWT implements EntryPoint {
|
||||||
|
/**
|
||||||
|
* The message displayed to the user when the server cannot be reached or
|
||||||
|
* returns an error.
|
||||||
|
*/
|
||||||
|
private static final String SERVER_ERROR = "An error occurred while "
|
||||||
|
+ "attempting to contact the server. Please check your network " + "connection and try again.";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a remote service proxy to talk to the server-side Greeting service.
|
||||||
|
*/
|
||||||
|
public interface JsClientBundle extends ClientBundle {
|
||||||
|
final JsClientBundle INSTANCE = GWT.create(JsClientBundle.class);
|
||||||
|
|
||||||
|
@Source("resources/gwt-react-bundle.min.js")
|
||||||
|
TextResource gwtreactbundlejs();
|
||||||
|
@Source("resources/gwt-react-router-bundle.min.js")
|
||||||
|
TextResource gwtreactrouterbundlejs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private final LoginServiceAsync loginService = GWT.create(LoginService.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the entry point method.
|
||||||
|
*/
|
||||||
|
final TextBox userNameField = new TextBox();
|
||||||
|
final TextBox passwordField = new PasswordTextBox();
|
||||||
|
final Button loginButton = new Button("LOGIN");
|
||||||
|
final Button goToReactButton = new Button("GO TO REACT APP");
|
||||||
|
final Label loggedUserInfo = new Label();
|
||||||
|
final Label errorLabel = new Label();
|
||||||
|
|
||||||
|
private void displayLoginWindow(boolean displayLogin){
|
||||||
|
// Hide info and React button
|
||||||
|
if(displayLogin)
|
||||||
|
loggedUserInfo.setText("");
|
||||||
|
|
||||||
|
goToReactButton.setVisible(!displayLogin);
|
||||||
|
RootPanel.get("userNameFieldLabel").setVisible(displayLogin);
|
||||||
|
RootPanel.get("passwordFieldLabel").setVisible(displayLogin);
|
||||||
|
userNameField.setVisible(displayLogin);
|
||||||
|
passwordField.setVisible(displayLogin);
|
||||||
|
loginButton.setVisible(displayLogin);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkWithServerIfSessionIdIsStillLegal(String sessionID)
|
||||||
|
{
|
||||||
|
loginService.loginFromSessionServer(new AsyncCallback<UserDTO>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught)
|
||||||
|
{
|
||||||
|
displayLoginWindow(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(UserDTO result)
|
||||||
|
{
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
displayLoginWindow(true);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
if (result.getLoggedIn())
|
||||||
|
{
|
||||||
|
displayLoginWindow(false);
|
||||||
|
loggedUserInfo.setText("Current logged in user: " + result.getUserName());
|
||||||
|
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
displayLoginWindow(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onModuleLoad() {
|
||||||
|
|
||||||
|
ScriptInjector.fromString(JsClientBundle.INSTANCE.gwtreactbundlejs().getText()).inject();
|
||||||
|
ScriptInjector.fromString(JsClientBundle.INSTANCE.gwtreactrouterbundlejs().getText()).inject();
|
||||||
|
|
||||||
|
|
||||||
|
// GWTReactBundleWrapper.injectScript();
|
||||||
|
// Add the nameField and sendButton to the RootPanel
|
||||||
|
// Use RootPanel.get() to get the entire body element
|
||||||
|
RootPanel.get("userNameFieldContainer").add(userNameField);
|
||||||
|
RootPanel.get("passwordFieldContainer").add(passwordField);
|
||||||
|
RootPanel.get("loginButtonContainer").add(loginButton);
|
||||||
|
RootPanel.get("errorLabelContainer").add(errorLabel);
|
||||||
|
RootPanel.get("loggedInUserInfoContainer").add(loggedUserInfo);
|
||||||
|
RootPanel.get("goToReactApplicationButtonContainer").add(goToReactButton);
|
||||||
|
|
||||||
|
// Focus the cursor on the name field when the app loads
|
||||||
|
userNameField.setFocus(true);
|
||||||
|
userNameField.selectAll();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
String sessionID = Cookies.getCookie("sid");
|
||||||
|
if (sessionID == null)
|
||||||
|
{
|
||||||
|
displayLoginWindow(true);
|
||||||
|
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
checkWithServerIfSessionIdIsStillLegal(sessionID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Create a handler for the sendButton and nameField
|
||||||
|
class MyHandler implements ClickHandler, KeyUpHandler {
|
||||||
|
/**
|
||||||
|
* Fired when the user clicks on the sendButton.
|
||||||
|
*/
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
Widget sender = (Widget) event.getSource();
|
||||||
|
if (sender == loginButton) {
|
||||||
|
loginUser();
|
||||||
|
} else if (sender == goToReactButton) {
|
||||||
|
Window.Location.replace("http://127.0.0.1:3000");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fired when the user types in the nameField.
|
||||||
|
*/
|
||||||
|
public void onKeyUp(KeyUpEvent event) {
|
||||||
|
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
|
||||||
|
loginUser();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void loginUser(){
|
||||||
|
|
||||||
|
loginService.loginServer(userNameField.getValue(), passwordField.getValue(), new AsyncCallback<UserDTO>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onSuccess(UserDTO result)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (result.getLoggedIn())
|
||||||
|
{
|
||||||
|
|
||||||
|
//set session cookie for 10s expiry.
|
||||||
|
String sessionID = result.getSessionId();
|
||||||
|
final long DURATION = 1000 * 60 * 10;
|
||||||
|
Date expires = new Date(System.currentTimeMillis() + DURATION);
|
||||||
|
Cookies.setCookie("sid", sessionID, expires, null, "/", false);
|
||||||
|
displayLoginWindow(false);
|
||||||
|
loggedUserInfo.setText("Current logged in user: " + result.getUserName());
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
Window.alert("Access Denied 1. Check your user-name and password.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught)
|
||||||
|
{
|
||||||
|
|
||||||
|
Window.alert("Access Denied 2. Check your user-name and password.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a handler to send the name to the server
|
||||||
|
MyHandler handler = new MyHandler();
|
||||||
|
loginButton.addClickHandler(handler);
|
||||||
|
passwordField.addKeyUpHandler(handler);
|
||||||
|
goToReactButton.addClickHandler(handler);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
8225
TestGWT/src/com/test/gwt/client/resources/gwt-react-bundle.js
Normal file
29
TestGWT/src/com/test/gwt/client/resources/gwt-react-bundle.min.js
vendored
Normal file
25
TestGWT/src/com/test/gwt/client/resources/gwt-react-router-bundle.min.js
vendored
Normal file
5
TestGWT/src/com/test/gwt/server/JSONLoginService.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package com.test.gwt.server;
|
||||||
|
|
||||||
|
public class JSONLoginService {
|
||||||
|
|
||||||
|
}
|
||||||
60
TestGWT/src/com/test/gwt/server/LoginServiceImpl.java
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
package com.test.gwt.server;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||||
|
import com.test.gwt.client.LoginService;
|
||||||
|
import com.test.gwt.shared.UserDTO;
|
||||||
|
|
||||||
|
public class LoginServiceImpl extends RemoteServiceServlet implements LoginService
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 4456105400553118785L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserDTO loginServer(String name, String password)
|
||||||
|
{
|
||||||
|
UserDTO user = new UserDTO(name, password);
|
||||||
|
storeUserInSession(user);
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserDTO loginFromSessionServer()
|
||||||
|
{
|
||||||
|
return getUserAlreadyFromSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void logout()
|
||||||
|
{
|
||||||
|
deleteUserFromSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
private UserDTO getUserAlreadyFromSession()
|
||||||
|
{
|
||||||
|
UserDTO user = null;
|
||||||
|
HttpServletRequest httpServletRequest = this.getThreadLocalRequest();
|
||||||
|
HttpSession session = httpServletRequest.getSession();
|
||||||
|
Object userObj = session.getAttribute("user");
|
||||||
|
if (userObj != null && userObj instanceof UserDTO)
|
||||||
|
{
|
||||||
|
user = (UserDTO) userObj;
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void storeUserInSession(UserDTO user)
|
||||||
|
{
|
||||||
|
HttpServletRequest httpServletRequest = this.getThreadLocalRequest();
|
||||||
|
HttpSession session = httpServletRequest.getSession(true);
|
||||||
|
user.setSessionId(session.getId());
|
||||||
|
session.setAttribute("user", user);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteUserFromSession()
|
||||||
|
{
|
||||||
|
HttpServletRequest httpServletRequest = this.getThreadLocalRequest();
|
||||||
|
HttpSession session = httpServletRequest.getSession();
|
||||||
|
session.removeAttribute("user");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
42
TestGWT/src/com/test/gwt/shared/FieldVerifier.java
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package com.test.gwt.shared;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* FieldVerifier validates that the name the user enters is valid.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* This class is in the <code>shared</code> package because we use it in both
|
||||||
|
* the client code and on the server. On the client, we verify that the name is
|
||||||
|
* valid before sending an RPC request so the user doesn't have to wait for a
|
||||||
|
* network round trip to get feedback. On the server, we verify that the name is
|
||||||
|
* correct to ensure that the input is correct regardless of where the RPC
|
||||||
|
* originates.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* When creating a class that is used on both the client and the server, be sure
|
||||||
|
* that all code is translatable and does not use native JavaScript. Code that
|
||||||
|
* is not translatable (such as code that interacts with a database or the file
|
||||||
|
* system) cannot be compiled into client-side JavaScript. Code that uses native
|
||||||
|
* JavaScript (such as Widgets) cannot be run on the server.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public class FieldVerifier {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies that the specified name is valid for our service.
|
||||||
|
*
|
||||||
|
* In this example, we only require that the name is at least four
|
||||||
|
* characters. In your application, you can use more complex checks to ensure
|
||||||
|
* that usernames, passwords, email addresses, URLs, and other fields have the
|
||||||
|
* proper syntax.
|
||||||
|
*
|
||||||
|
* @param name the name to validate
|
||||||
|
* @return true if valid, false if invalid
|
||||||
|
*/
|
||||||
|
public static boolean isValidName(String name) {
|
||||||
|
if (name == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return name.length() > 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
59
TestGWT/src/com/test/gwt/shared/UserDTO.java
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
package com.test.gwt.shared;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class UserDTO implements Serializable
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 3196402615838002153L;
|
||||||
|
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
private boolean loggedIn;
|
||||||
|
|
||||||
|
private String sessionId;
|
||||||
|
|
||||||
|
public UserDTO()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserDTO(String name, String password)
|
||||||
|
{
|
||||||
|
setUserName(name);
|
||||||
|
setPassword(password);
|
||||||
|
setLoggedIn(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserName(String userName) {
|
||||||
|
this.userName = userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getLoggedIn() {
|
||||||
|
return loggedIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoggedIn(boolean loggedIn) {
|
||||||
|
this.loggedIn = loggedIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSessionId() {
|
||||||
|
return sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSessionId(String sessionId) {
|
||||||
|
this.sessionId = sessionId;
|
||||||
|
}
|
||||||
|
}
|
||||||
34
TestGWT/war/TestGWT.css
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/** Add css rules here for your application. */
|
||||||
|
|
||||||
|
|
||||||
|
/** Example rules used by the template application (remove for your app) */
|
||||||
|
h1 {
|
||||||
|
font-size: 2em;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #777777;
|
||||||
|
margin: 40px 0px 70px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sendButton {
|
||||||
|
display: block;
|
||||||
|
font-size: 16pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Most GWT widgets already have a style name defined */
|
||||||
|
.gwt-DialogBox {
|
||||||
|
width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialogVPanel {
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.serverResponseLabelError {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set ids using widget.getElement().setId("idOfElement") */
|
||||||
|
#closeButton {
|
||||||
|
margin: 15px 6px 6px;
|
||||||
|
}
|
||||||
75
TestGWT/war/TestGWT.html
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<!-- The DOCTYPE declaration above will set the -->
|
||||||
|
<!-- browser's rendering engine into -->
|
||||||
|
<!-- "Standards Mode". Replacing this declaration -->
|
||||||
|
<!-- with a "Quirks Mode" doctype is not supported. -->
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
|
|
||||||
|
<!-- -->
|
||||||
|
<!-- Consider inlining CSS to reduce the number of requested files -->
|
||||||
|
<!-- -->
|
||||||
|
<link type="text/css" rel="stylesheet" href="TestGWT.css">
|
||||||
|
|
||||||
|
<!-- -->
|
||||||
|
<!-- Any title is fine -->
|
||||||
|
<!-- -->
|
||||||
|
<title>Web Application Starter Project</title>
|
||||||
|
|
||||||
|
<!-- -->
|
||||||
|
<!-- This script loads your compiled module. -->
|
||||||
|
<!-- If you add any GWT meta tags, they must -->
|
||||||
|
<!-- be added before this line. -->
|
||||||
|
<!-- -->
|
||||||
|
<script type="text/javascript" src="testgwt/testgwt.nocache.js"></script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<!-- -->
|
||||||
|
<!-- The body can have arbitrary html, or -->
|
||||||
|
<!-- you can leave the body empty if you want -->
|
||||||
|
<!-- to create a completely dynamic UI. -->
|
||||||
|
<!-- -->
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
|
||||||
|
<noscript>
|
||||||
|
<div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
|
||||||
|
Your web browser must have JavaScript enabled
|
||||||
|
in order for this application to display correctly.
|
||||||
|
</div>
|
||||||
|
</noscript>
|
||||||
|
|
||||||
|
<h1>Test application - GWT</h1>
|
||||||
|
|
||||||
|
<table align="center" >
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" id="userNameFieldLabel" style="font-size: large;">Username:</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td id="userNameFieldContainer"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" id="passwordFieldLabel" style="font-size: large;">Password:</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td id="passwordFieldContainer"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td id="loginButtonContainer"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" id="loggedInUserInfoContainer" style="font-size: large;"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td id="goToReactApplicationButtonContainer"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" style="color:red;" id="errorLabelContainer"></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
BIN
TestGWT/war/WEB-INF/classes/.DS_Store
vendored
Normal file
BIN
TestGWT/war/WEB-INF/classes/com/.DS_Store
vendored
Normal file
BIN
TestGWT/war/WEB-INF/classes/com/test/.DS_Store
vendored
Normal file
BIN
TestGWT/war/WEB-INF/classes/com/test/gwt/.DS_Store
vendored
Normal file
42
TestGWT/war/WEB-INF/classes/com/test/gwt/TestGWT.gwt.xml
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
When updating your version of GWT, you should also update this DTD reference,
|
||||||
|
so that your app can take advantage of the latest GWT module capabilities.
|
||||||
|
-->
|
||||||
|
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.7.0//EN"
|
||||||
|
"http://gwtproject.org/doctype/2.7.0/gwt-module.dtd">
|
||||||
|
<module rename-to='testgwt'>
|
||||||
|
<!-- Inherit the core Web Toolkit stuff. -->
|
||||||
|
<inherits name='com.google.gwt.user.User'/>
|
||||||
|
|
||||||
|
<!-- Inherit the default GWT style sheet. You can change -->
|
||||||
|
<!-- the theme of your GWT application by uncommenting -->
|
||||||
|
<!-- any one of the following lines. -->
|
||||||
|
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
|
||||||
|
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
|
||||||
|
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
|
||||||
|
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
|
||||||
|
|
||||||
|
|
||||||
|
<inherits name="com.google.gwt.resources.Resources" />
|
||||||
|
<inherits name="gwt.react.React" />
|
||||||
|
<inherits name="gwt.redux.Redux" />
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Other module inherits -->
|
||||||
|
<!-- Specify the app entry point class. -->
|
||||||
|
<entry-point class='com.test.gwt.client.TestGWT'/>
|
||||||
|
|
||||||
|
<!-- Specify the paths for translatable code -->
|
||||||
|
<source path='client'/>
|
||||||
|
|
||||||
|
|
||||||
|
<set-configuration-property name="CssResource.style" value="pretty" />
|
||||||
|
<set-configuration-property name="CssResource.obfuscationPrefix" value="empty" />
|
||||||
|
|
||||||
|
<!-- allow Super Dev Mode -->
|
||||||
|
<add-linker name="xsiframe"/>
|
||||||
|
<set-configuration-property name="devModeRedirectEnabled" value="true"/>
|
||||||
|
<set-property name="compiler.useSourceMaps" value="true" />
|
||||||
|
|
||||||
|
</module>
|
||||||
29
TestGWT/war/WEB-INF/classes/com/test/gwt/client/resources/gwt-react-bundle.min.js
vendored
Normal file
25
TestGWT/war/WEB-INF/classes/com/test/gwt/client/resources/gwt-react-router-bundle.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Module testgwt
|
||||||
|
# RPC service class, partial path of RPC policy file
|
||||||
24
TestGWT/war/WEB-INF/web.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
|
||||||
|
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||||
|
version="2.5"
|
||||||
|
xmlns="http://java.sun.com/xml/ns/javaee">
|
||||||
|
|
||||||
|
<!-- Servlets -->
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>LoginServiceImpl</servlet-name>
|
||||||
|
<servlet-class>com.test.gwt.server.LoginServiceImpl</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>LoginServiceImpl</servlet-name>
|
||||||
|
<url-pattern>/testgwt/login</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<!-- Default page to serve -->
|
||||||
|
<welcome-file-list>
|
||||||
|
<welcome-file>TestGWT.html</welcome-file>
|
||||||
|
</welcome-file-list>
|
||||||
|
|
||||||
|
</web-app>
|
||||||
BIN
TestGWT/war/favicon.ico
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
10
TestGWT/war/testgwt/30DAA66EA6B7DFDBCBC4CBEBFE60A578.gwt.rpc
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
@FinalFields, false
|
||||||
|
com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException, true, true, true, true, com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException/3936916533, 3936916533
|
||||||
|
com.google.gwt.user.client.rpc.RpcTokenException, true, true, false, false, com.google.gwt.user.client.rpc.RpcTokenException/2345075298, 2345075298
|
||||||
|
com.google.gwt.user.client.rpc.XsrfToken, false, false, true, true, com.google.gwt.user.client.rpc.XsrfToken/4254043109, 4254043109
|
||||||
|
com.test.gwt.client.LoginService, false, false, false, false, _, 2952424308
|
||||||
|
com.test.gwt.shared.UserDTO, true, true, false, false, com.test.gwt.shared.UserDTO/3475737550, 3475737550
|
||||||
|
java.lang.Exception, true, false, true, false, java.lang.Exception/1920171873, 1920171873
|
||||||
|
java.lang.RuntimeException, true, false, true, false, java.lang.RuntimeException/515124647, 515124647
|
||||||
|
java.lang.String, true, true, true, true, java.lang.String/2004016611, 2004016611
|
||||||
|
java.lang.Throwable, true, false, true, false, java.lang.Throwable/2953622131, 2953622131
|
||||||
11
TestGWT/war/testgwt/914294B2A8BA55569E4354AC39D4D02B.gwt.rpc
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
@FinalFields, false
|
||||||
|
com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException, true, true, true, true, com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException/3936916533, 3936916533
|
||||||
|
com.google.gwt.user.client.rpc.RpcTokenException, true, true, false, false, com.google.gwt.user.client.rpc.RpcTokenException/2345075298, 2345075298
|
||||||
|
com.google.gwt.user.client.rpc.XsrfToken, false, false, true, true, com.google.gwt.user.client.rpc.XsrfToken/4254043109, 4254043109
|
||||||
|
com.test.gwt.client.GreetingService, false, false, false, false, _, 1506885743
|
||||||
|
java.lang.Exception, true, false, true, false, java.lang.Exception/1920171873, 1920171873
|
||||||
|
java.lang.IllegalArgumentException, true, true, false, false, java.lang.IllegalArgumentException/1755012560, 1755012560
|
||||||
|
java.lang.NumberFormatException, true, true, false, false, java.lang.NumberFormatException/3305228476, 3305228476
|
||||||
|
java.lang.RuntimeException, true, false, true, false, java.lang.RuntimeException/515124647, 515124647
|
||||||
|
java.lang.String, true, true, true, true, java.lang.String/2004016611, 2004016611
|
||||||
|
java.lang.Throwable, true, false, true, false, java.lang.Throwable/2953622131, 2953622131
|
||||||
BIN
TestGWT/war/testgwt/clear.cache.gif
Normal file
|
After Width: | Height: | Size: 43 B |
8225
TestGWT/war/testgwt/gwt-react-bundle.js
Normal file
1121
TestGWT/war/testgwt/gwt/clean/clean.css
Normal file
1122
TestGWT/war/testgwt/gwt/clean/clean_rtl.css
Normal file
BIN
TestGWT/war/testgwt/gwt/clean/images/circles.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
TestGWT/war/testgwt/gwt/clean/images/corner.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
TestGWT/war/testgwt/gwt/clean/images/hborder.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
TestGWT/war/testgwt/gwt/clean/images/thumb_horz.png
Normal file
|
After Width: | Height: | Size: 222 B |
BIN
TestGWT/war/testgwt/gwt/clean/images/thumb_vertical.png
Normal file
|
After Width: | Height: | Size: 231 B |
BIN
TestGWT/war/testgwt/gwt/clean/images/vborder.png
Normal file
|
After Width: | Height: | Size: 298 B |
1
TestGWT/war/testgwt/testgwt.devmode.js
Normal file
67
TestGWT/war/testgwt/testgwt.nocache.js
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 Google Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations under
|
||||||
|
* the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This startup script is used when we run superdevmode from an app server.
|
||||||
|
*/
|
||||||
|
(function($wnd, $doc){
|
||||||
|
// document.head does not exist in IE8
|
||||||
|
var $head = $doc.head || $doc.getElementsByTagName('head')[0];
|
||||||
|
// Compute some codeserver urls so as the user does not need bookmarklets
|
||||||
|
var hostName = $wnd.location.hostname;
|
||||||
|
var serverUrl = 'http://' + hostName + ':9876';
|
||||||
|
var module = 'testgwt';
|
||||||
|
var nocacheUrl = serverUrl + '/recompile-requester/' + module;
|
||||||
|
|
||||||
|
// Insert the superdevmode nocache script in the first position of the head
|
||||||
|
var devModeScript = $doc.createElement('script');
|
||||||
|
devModeScript.src = nocacheUrl;
|
||||||
|
|
||||||
|
// Everybody except IE8 does fire an error event
|
||||||
|
// This means that we do not detect a non running SDM with IE8.
|
||||||
|
if (devModeScript.addEventListener) {
|
||||||
|
var callback = function() {
|
||||||
|
// Don't show the confirmation dialogue twice (multimodule)
|
||||||
|
if (!$wnd.__gwt__sdm__confirmed &&
|
||||||
|
(!$wnd.__gwt_sdm__recompiler || !$wnd.__gwt_sdm__recompiler.loaded)) {
|
||||||
|
$wnd.__gwt__sdm__confirmed = true;
|
||||||
|
if ($wnd.confirm(
|
||||||
|
"Couldn't load " + module + " from Super Dev Mode\n" +
|
||||||
|
"server at " + serverUrl + ".\n" +
|
||||||
|
"Please make sure this server is ready.\n" +
|
||||||
|
"Do you want to try again?")) {
|
||||||
|
$wnd.location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
devModeScript.addEventListener("error", callback, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
var injectScriptTag = function(){
|
||||||
|
$head.insertBefore(devModeScript, $head.firstElementChild || $head.children[0]);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (/loaded|complete/.test($doc.readyState)) {
|
||||||
|
injectScriptTag();
|
||||||
|
} else {
|
||||||
|
//defer app script insertion until the body is ready
|
||||||
|
if($wnd.addEventListener){
|
||||||
|
$wnd.addEventListener('load', injectScriptTag, false);
|
||||||
|
} else{
|
||||||
|
$wnd.attachEvent('onload', injectScriptTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})(window, document);
|
||||||