This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
models.createModels(mongoose, function() { | |
app.TestUser = TestUser = mongoose.model('TestUser'); | |
db = mongoose.connect('mongodb://localhost/testdb'); | |
console.log("Database Started"); | |
}) | |
function createModels(mongoose, fn) { | |
var Schema = mongoose.Schema; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create user | |
app.post('/newuser', function(req, res) { | |
var d = new TestUser(req.body.d); | |
d.save(function() { | |
TestUser.find({}, function(err, user) { | |
user = user.map(function(u) { | |
return { username: u.username, password: u.password }; | |
}); | |
res.render('user/index.jade', { | |
locals: { d: user } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//create an app server | |
var express = require('express'), | |
jade = require('jade'), | |
app = module.exports = express.createServer(), | |
mongoose = require('mongoose'), | |
models = require('./models/model.js'), | |
stylus = require('stylus'), | |
db, | |
TestUser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// User list | |
app.get('/userlist', function(req, res) { | |
TestUser.find({}, function(err, user) { | |
user = user.map(function(u) { | |
return { username: u.username, password: d.password }; | |
}); | |
res.render('user/index.jade', { | |
locals: { d: user } | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void onModuleLoad() { | |
RootPanel rootPanel = RootPanel.get(); | |
LayoutPanel layoutPanel = new LayoutPanel(); | |
rootPanel.add(layoutPanel, 10, 0); | |
layoutPanel.setSize("430px", "290px"); | |
Label lblName = new Label("Name"); | |
layoutPanel.add(lblName); | |
layoutPanel.setWidgetLeftWidth(lblName, 40.0, Unit.PX, 56.0, Unit.PX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<module rename-to='gwtwebappdemo'> | |
<inherits name='com.google.gwt.user.User' /> | |
<inherits name='com.google.gwt.user.theme.clean.Clean' /> | |
<source path='client' /> | |
<source path='shared' /> | |
<entry-point class="com.example.gwt.client.GwtDemoAppClient"></entry-point> | |
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
<link type="text/css" rel="stylesheet" href="GwtWebAppDemo.css"> | |
<title>GWT Web App Demo Project</title> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Button btnAdd = new Button("Add"); | |
btnAdd.addClickHandler(new ClickHandler() { | |
public void onClick(ClickEvent event) { | |
User user = new User(); | |
user.setUserName(nameTextBox.getText()); | |
user.setPassword(passwordTextBox.getText()); | |
MongoDBServiceAsync mongoDBServiceAsync = GWT | |
.create(MongoDBService.class); | |
ServiceDefTarget serviceDef = (ServiceDefTarget) mongoDBServiceAsync; | |
serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.gwt.client; | |
import java.util.List; | |
import com.example.gwt.client.modal.User; | |
import com.google.gwt.user.client.rpc.RemoteService; | |
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; | |
@RemoteServiceRelativePath("dbservice") | |
public interface MongoDBService extends RemoteService { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.gwt.client; | |
import java.util.List; | |
import com.example.gwt.client.modal.User; | |
import com.google.gwt.user.client.rpc.AsyncCallback; | |
public interface MongoDBServiceAsync { | |
void getAllUsers(AsyncCallback<List<String>> callback); |
OlderNewer