Skip to content

Instantly share code, notes, and snippets.

/**
* Form post handler
*/
@RequestMapping(value = "/", method = RequestMethod.POST)
public String send(
@Valid @ModelAttribute("messageForm") MessageForm messageForm,
BindingResult binding,
RedirectAttributes redirectAttributes) {
// Redirect back into form page if errors detected
// list page
@RequestMapping(value = "/users", method = RequestMethod.GET)
public String showAllUsers(Model model) {
logger.debug("showAllUsers()");
model.addAttribute("users", userService.findAll());
return "users/list";
}
package com.howtodoinjava.demo.model;
import java.io.Serializable;
public class EmployeeVO implements Serializable
{
private static final long serialVersionUID = 1L;
private Integer id;
private String firstName;
package com.howtodoinjava.demo.validator;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;
import com.howtodoinjava.demo.model.EmployeeVO;
@Component
public class Messages {
// property file is: package/name/messages.properties
private static final String BUNDLE_NAME = "package.name.messages";
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
private Messages() {
}
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
package com.concretepage.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import com.concretepage.bean.UserInfo;
@Repository
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
Include file (Java)
<%@ include file="/WEB-INF/jsp/common/date.jsp" %>
Include file (JSP)
<jsp:include page="/WEB-INF/jsp/common/date.jsp">
var ProductsApi = {
loadAll: function() {
return APIUtils.get('/products');
}
};
var ProductActions = Reflux.createActions(['loadAll', 'loadAllComplete']);
ProductActions.loadAll.preEmit = function() {
ProductsApi.loadAll().then(ProductActions.loadAllComplete);
};
@vy-nguyen
vy-nguyen / Same react code
Last active March 5, 2016 17:54
React sample code
var Login = React.createClass({
mixins: [Reflux.listenTo(userStore, 'resetForm')],
resetForm: function() {
this.setState({
submitted: false,
});
this.refs.email.getDOMNode().value = '';
this.refs.password.getDOMNode().value = '';
@vy-nguyen
vy-nguyen / gist:b214bdc402edab61147a
Last active March 16, 2016 08:31
Login example
App.Users.Add = React.createClass({
getInitialState: function () {
return {username: "", email: "", password: "", loading: false, errors: {}}
},
_create: function () {
return $.ajax({
url: '/api/users',
type: 'POST',
data: {
username: this.state.username,