MentaTutorials

Compare Revisions

Ignore whitespace Rev 52 → Rev 53

/MentaRefAppWithService/trunk/src/main/java/org/menta/model/User.java
16,6 → 16,21
private int groupId;
private Sexo sexo;
public static enum Sexo {
MASCULINO,
FEMININO;
public int getId() {
return ordinal();
}
public static Sexo fromId(int id) {
return id == 0 ? MASCULINO : FEMININO;
}
}
public User() { }
 
public int getId() {
78,4 → 93,12
public void setGroupId(int groupId) {
this.groupId = groupId;
}
 
public Sexo getSexo() {
return sexo;
}
 
public void setSexo(Sexo sexo) {
this.sexo = sexo;
}
}
/MentaRefAppWithService/trunk/src/main/java/org/menta/AppManager.java
1,5 → 1,6
package org.menta;
 
import java.io.IOException;
import java.sql.Connection;
 
import org.menta.action.LoginAction;
9,6 → 10,7
import org.menta.model.Group;
import org.menta.model.Language;
import org.menta.model.User;
import org.menta.model.User.Sexo;
import org.menta.service.UserService;
import org.menta.service.impl.UserServiceImpl;
import org.mentabean.BeanSession;
26,6 → 28,8
import org.mentawai.filter.MentaContainerFilter;
import org.mentawai.filter.TransactionFilter;
import org.mentawai.filter.ValidationFilter;
import org.mentawai.list.BaseListData;
import org.mentawai.list.ListManager;
import org.mentawai.mail.Email;
 
public class AppManager extends ApplicationManager {
97,11 → 101,20
.field("password", DBTypes.STRING)
.field("email", DBTypes.STRING)
.field("languageId", "language_id", DBTypes.INTEGER)
.field("groupId", "group_id", DBTypes.INTEGER);
.field("groupId", "group_id", DBTypes.INTEGER)
.field("sexo","sexo", DBTypes.ENUMID.from(Sexo.class));
}
@Override
public void loadLists() {
try {
ListManager.addList( new BaseListData("sexo", BaseListData.ORDER_BY_ID) );
} catch (IOException e) {
e.printStackTrace();
}
addLocalizedLists("groups", "languages");
}
/MentaRefAppWithService/trunk/src/main/java/org/menta/action/UserAction.java
40,8 → 40,11
} else if (method != null && method.equals("edit") && isPost()) {
 
val.requiredFields("required_field", "username", "email", "groupId");
// declare cripted fields to validate and convert them
val.criptedFields("decript_error", "id", "groupId", "sexo", "languageId");
val.requiredFields("required_field", "username", "email", "groupId", "languageId");
val.requiredLists("required_field", "groupId");
val.add("username", RegexRule.getInstance(username_regex), "bad_username");
/MentaRefAppWithService/trunk/src/main/webapp/i18n/master_pt_BR.i18n
18,6 → 18,7
UserAction.username_already_exists = Esse apelido já existe!
UserAction.registration_ok = Seu cadastro foi efetuado com sucesso!
UserAction.edit_ok = Informações alteradas com sucesso!
UserAction.decript_error = Não tente quebrar a segurança!
 
# index.jsp
 
59,7 → 60,7
user.edit.language = Idioma:
user.edit.username_error = Erro checando apelido!
user.edit.username_already = Apelido já existe!
user.edit.sexo = Sexo
 
 
 
 
/MentaRefAppWithService/trunk/src/main/webapp/i18n/master_en_US.i18n
18,6 → 18,7
UserAction.username_already_exists = Username already exists!
UserAction.registration_ok = Registration successful!
UserAction.edit_ok = Account saved!
UserAction.decript_error = Don't try to break the security!
 
# index.jsp
 
59,8 → 60,8
user.edit.language = Language:
user.edit.username_error = Error checking username!
user.edit.username_already = Username already exists!
user.edit.sexo = Gender
 
 
 
 
 
/MentaRefAppWithService/trunk/src/main/webapp/WEB-INF/db/menta.sql
81,6 → 81,7
`email` varchar(100) DEFAULT NULL,
`group_id` int(11) DEFAULT NULL,
`language_id` int(11) DEFAULT NULL,
`sexo` int(1) DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `users_username` (`username`)
);
91,7 → 92,7
--
 
 
INSERT INTO `users` VALUES (2,'soliveira','abc123','sergio@email.com.br',2,2),(3,'saoj','abc123','abc@abc.com',1,1),(5,'pelasaco','abc123','pela@pela.com.br',3,1),(6,'dilma','abc123','dilma@adsf.com',2,2),(7,'diego','abc123','de@de.com',2,2),(8,'adriano','abc123','sergio@email.com',2,2),(9,'adriano2','abc123','sergio@email.com',2,2),(10,'adriano3','sergio','sergio@email.com',3,2),(11,'porta','abc123','porta@porta.com.br',3,2),(12,'porta1111','abc123','porta@porta.com.br',3,2),(13,'porta22','abc123','sergio.oliveira.jr@gmail.com',2,2),(14,'asdfasdf','abc','asdf@asdf423.com',3,1);
INSERT INTO `users` VALUES (2,'soliveira','abc123','sergio@email.com.br',2,2,0),(3,'saoj','abc123','abc@abc.com',1,1,0),(5,'pelasaco','abc123','pela@pela.com.br',3,1,0),(6,'dilma','abc123','dilma@adsf.com',2,2,0),(7,'diego','abc123','de@de.com',2,2,0),(8,'adriano','abc123','sergio@email.com',2,2,0),(9,'adriano2','abc123','sergio@email.com',2,2,0),(10,'adriano3','sergio','sergio@email.com',3,2,0),(11,'porta','abc123','porta@porta.com.br',3,2,0),(12,'porta1111','abc123','porta@porta.com.br',3,2,0),(13,'porta22','abc123','sergio.oliveira.jr@gmail.com',2,2,0),(14,'asdfasdf','abc','asdf@asdf423.com',3,1,0);
 
 
 
/MentaRefAppWithService/trunk/src/main/webapp/jsp/user/edit.jsp
1,5 → 1,5
<%@ page contentType="text/html; charset=UTF-8" %>
<%@taglib prefix="mtw" uri="http://www.mentaframework.org/tags-mtw/" %>
<%@taglib prefix="mtw" uri="http://www.mentaframework.org/tags-mtw/"%>
 
<mtw:useI18N prefix="user.edit" />
 
82,9 → 82,14
 
<form action="<mtw:contextPath />/User.edit.mtw" method="post">
<mtw:bean value="user">
<mtw:input type="hidden" name="id" cript="true" />
<span>
Hidden id : <b> ${user.id}</b><br/>
Cripted : <b> ${mtw:cript(user.id)}</b>
</span>
<table>
<mtw:input type="hidden" name="id" />
<tr>
<td><mtw:i18n key="username" /></td>
<td>
108,16 → 113,28
</td>
</tr>
<tr>
<td><mtw:i18n key="sexo" /></td>
<td>
<mtw:input type="radio" name="sexo" value="MASCULINO" cript="true" /> Masculino
&nbsp;
<mtw:input type="radio" name="sexo" value="FEMININO" cript="true" /> Feminino
<mtw:outError field="sexo">
<font color="red"> <b><mtw:out /></b> </font>
</mtw:outError>
</td>
</tr>
<tr>
<td><mtw:i18n key="group" /></td>
<td>
<mtw:select name="groupId" list="groups" />
<mtw:select name="groupId" list="groups" cript="true" />
<mtw:outError field="groupId">
<font color="red"> <b><mtw:out /></b> </font>
</mtw:outError></td>
</tr>
<tr>
<td><mtw:i18n key="language" /></td>
<td><mtw:select name="languageId" list="languages" />
<td><mtw:radiobuttons name="languageId" list="languages" cript="true" />
<mtw:outError field="languageId">
<font color="red"> <b><mtw:out /></b> </font>
</mtw:outError>
/MentaRefAppWithService/trunk/src/main/webapp/jsp/user/add.jsp
140,6 → 140,14
</td>
</tr>
<tr>
<td><mtw:i18n key="sexo" /></td>
<td><mtw:select name="sexo" list="sexo"/>
<mtw:outError field="sexo">
<font color="red"> <b><mtw:out /></b> </font>
</mtw:outError>
</td>
</tr>
<tr>
<td>
<mtw:i18n key="group" />
</td>
/MentaRefAppWithService/trunk/src/main/webapp/lists/sexo_pt_BR.i18n
New file
0,0 → 1,2
MASCULINO=Masculino
FEMININO=Feminino
/MentaRefAppWithService/trunk/src/main/webapp/lists/sexo_en_US.i18n
New file
0,0 → 1,2
MASCULINO=Male
FEMININO=Female
/MentaRefAppWithService/trunk/pom.xml
1,4 → 1,5
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.mentawai</groupId>
<artifactId>mentaservice</artifactId>
16,6 → 17,12
<dependencies>
 
<dependency>
<groupId>me.soliveirajr</groupId>
<artifactId>mentawai</artifactId>
<version>2.5.4-SNAPSHOT</version>
</dependency>
 
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
42,37 → 49,31
<version>1.2.138</version>
</dependency>
 
<dependency>
<groupId>me.soliveirajr</groupId>
<artifactId>mentawai</artifactId>
<version>2.5.3</version>
</dependency>
 
</dependencies>
 
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.1.0.v20100505</version>
<configuration>
<webApp>${basedir}/target/${project.artifactId}.war</webApp>
<webAppConfig>
<contextPath>/${project.artifactId}</contextPath>
</webAppConfig>
<reload>manual</reload>
<connectors>
<connector implementation="org.eclipse.jetty.server.bio.SocketConnector">
<port>8080</port>
</connector>
</connectors>
</configuration>
</plugin>
 
 
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.1.0.v20100505</version>
<configuration>
<webApp>${basedir}/target/${project.artifactId}.war</webApp>
<webAppConfig>
<contextPath>/${project.artifactId}</contextPath>
</webAppConfig>
<reload>manual</reload>
<connectors>
<connector implementation="org.eclipse.jetty.server.bio.SocketConnector">
<port>8080</port>
</connector>
</connectors>
</configuration>
</plugin>
 
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>