Modifications de choose preference et début d'écran du CU d'inscription

This commit is contained in:
2008-01-10 11:13:42 +00:00
parent 2cf2c73e65
commit 01889e0fea
12 changed files with 282 additions and 22 deletions

View File

@@ -21,10 +21,13 @@
<div id="main_content">
<h2 align="center"><fmt:message key="preference.title" /></h2>
<c:if test="${message}">
<fmt:message key="${message}"/>
</c:if>
<form:form method="post" commandName="choosePreference">
<c:if test="${not empty articleList}">
<c:if test="${not empty articleList}">
<table>
<c:forEach items="${articleList}" var="article" varStatus="i">

View File

@@ -38,13 +38,13 @@
<input name="idArticle" type="hidden" value="${article.id}" />
<select path="member">
<form:select path="member">
<c:forEach var="m" items="${members}">
<option value="${m.login}">
${m.firstName} ${m.lastName}(0)
</option>
</c:forEach>
</select>
</form:select>
<input type="submit" value="add" />
</form:form>

View File

@@ -0,0 +1,56 @@
<%@ include file="/WEB-INF/jsp/include.jsp"%>
<%@ page session="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title><fmt:message key="title"/></title>
<link rel="stylesheet" href="./stylesheets/base.css" type="text/css" />
</head>
<body>
<jsp:include page="/WEB-INF/jsp/header.jsp" />
<div class="mainBloc">
<div class="header">&nbsp;</div>
<div class="content">
<jsp:include page="/WEB-INF/jsp/menu.jsp" />
<div id="main_content">
<h2 align="center"><fmt:message key="register.title" /></h2>
<form:form method="post" commandName="registerUser">
<form:label path="login"><fmt:message key="form.register.user.login" /></form:label> <form:input path="login"/> <br/><br />
<form:label path="email"><fmt:message key="form.register.user.email" /></form:label> <form:input path="email"/> <br/><br />
<form:label path="password"><fmt:message key="form.register.user.password" /></form:label> <form:password path="password"/> <br/><br />
<form:label path="passwordConfirm"><fmt:message key="form.register.user.passwordConfirm" /></form:label> <form:password path="passwordConfirm"/> <br/><br />
<form:label path="firstName"><fmt:message key="form.register.user.firstName" /></form:label> <form:input path="firstName"/> <br/><br />
<form:label path="lastName"><fmt:message key="form.register.user.lastName" /></form:label> <form:input path="lastName"/> <br/><br />
<form:label path="organization"><fmt:message key="form.register.user.organization" /></form:label> <form:input path="organization"/> <br/><br />
<input type="reset" value="<fmt:message key="button.reset" />"/>
<input type="submit" value="<fmt:message key="button.OK" />"/> <br/><br/>
</form:form>
<a href="<c:url value="main.htm"/>">Home</a>
</div>
</div>
<div class="footer">&nbsp;</div>
</div>
</body>
</html>

View File

@@ -39,7 +39,7 @@
<property name="commandName" value="choosePreference"/>
<property name="commandClass" value="org.yacos.web.PCmember.form.FormPreference" />
<property name="formView" value="choosePreference" />
<property name="successView" value="choosePreferenceOK" />
<property name="successView" value="choosePreference.htm" />
<property name="articleManager" ref="articleManager" />
<property name="usersManager" ref="usersManager" />
</bean>

View File

@@ -6,12 +6,9 @@ import org.springframework.web.servlet.ModelAndView;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.IOException;
import java.util.Date;
public class ChoosePreferenceControllerOK extends SimpleFormController {

View File

@@ -5,7 +5,6 @@ import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.validation.BindException;

View File

@@ -2,16 +2,12 @@ package org.yacos.web.PCmember.controller;
import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import org.yacos.core.article.*;

View File

@@ -6,12 +6,9 @@ import org.springframework.web.servlet.ModelAndView;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.IOException;
import java.util.Date;
public class MainController extends SimpleFormController {

View File

@@ -36,7 +36,8 @@ public class SArticleController extends SimpleFormController {
String title = ((FormSubmission) command).getTitle();
String theme = ((FormSubmission) command).getTheme();
String mainauthor = ((FormSubmission) command).getMainauthor();
String secondaryauthor = ((FormSubmission) command).getSecondaryauthor();
//String secondaryauthor = ((FormSubmission) command).getSecondaryauthor();
//TODO : get secondary author working
List<String> liste = ((FormSubmission) command).getListe();
String nomFile="";
@@ -66,7 +67,7 @@ public class SArticleController extends SimpleFormController {
System.out.println(e);
}
Article a = new Article(0, title, theme, nomFile, mainauthor, null, 1);
Article a = new Article(0, title, theme, nomFile, mainauthor, liste, 1);
articleManager.addArticle(a);
return new ModelAndView(new RedirectView(getSuccessView()));

View File

@@ -2,16 +2,12 @@ package org.yacos.web.author.controller;
import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.IOException;
import java.util.Date;
public class SArticleControllerOK extends SimpleFormController {

View File

@@ -0,0 +1,86 @@
/**
*
*/
package org.yacos.web.system.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import org.yacos.core.article.IArticleManager;
import org.yacos.core.users.IUserManager;
import org.yacos.core.users.User;
import org.yacos.core.users.UserManagerBean;
import org.yacos.web.system.form.FormUser;
/**
* FormController class for the user Sign In scenario (user registration)
*
* TODO: implement the invitation system
*
* @author christiancorsano
*
*/
public class SUserController extends SimpleFormController {
private IUserManager userManager;
/**
* @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.validation.BindException)
*/
@Override
protected ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response, Object command, BindException errors)
throws Exception {
FormUser userCommand = (FormUser) command;
User user = (User) request.getSession().getAttribute("currentUser");
if((user == null) && (userManager.getUser(userCommand.getLogin()) != null)){
// TODO : we have an "already registered" error here, handle it
}
if(user == null){
user = new User();
}
user.setLogin(userCommand.getLogin());
user.setEmail(userCommand.getEmail());
user.setFirstName(userCommand.getFirstName());
user.setLastName(userCommand.getLastName());
user.setOrganization(userCommand.getOrganization());
if(userCommand.passwordWasModified()){
user.setPassword(userCommand.getPassword());
}
// TODO Auto-generated method stub
return super.onSubmit(request, response, command, errors);
}
/**
* @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
*/
@Override
protected Object formBackingObject(HttpServletRequest request)
throws Exception {
FormUser user = new FormUser();
// We try to see if the user is already registered and logged
User currentUser = new User();
// TODO : see how JAAS could change the way of getting the current User
if(request.getSession().getAttribute("currentUser") != null){
// If he is logged, we use his profile information to fill the form
currentUser = (User) request.getSession().getAttribute("currentUser");
}
user.setLogin(currentUser.getLogin());
user.setFirstName(currentUser.getFirstName());
user.setLastName(currentUser.getLastName());
user.setEmail(currentUser.getEmail());
user.setOrganization(currentUser.getOrganization());
return super.formBackingObject(request);
}
}

View File

@@ -0,0 +1,129 @@
package org.yacos.web.system.form;
import java.sql.Time;
import java.util.Date;
import java.util.Random;
import sun.security.krb5.internal.Ticket;
/**
*
* @author christiancorsano
*
*/
public class FormUser {
private String login;
private String email;
private String password;
private String passwordConfirm;
private String firstName;
private String lastName;
private String organization;
private String passwordPlaceholderValue;
public FormUser() {
this.login = "";
this.email = "";
// We can't use the real password of the user, so we generate
// a hopefully unique placeholder value, that we will be able to check for modification at validation
Random placeholderSeed = new Random(new Date().getTime());
this.passwordPlaceholderValue = "placeholder"+placeholderSeed.nextInt();
this.password = this.passwordPlaceholderValue;
this.passwordConfirm = this.passwordPlaceholderValue;
this.firstName = "";
this.lastName = "";
this.organization = "";
}
/**
* @return the login
*/
public String getLogin() {
return login;
}
/**
* @param login the login to set
*/
public void setLogin(String login) {
this.login = login;
}
/**
* @return the email
*/
public String getEmail() {
return email;
}
/**
* @param email the email to set
*/
public void setEmail(String email) {
this.email = email;
}
/**
* @return the password
*/
public String getPassword() {
return password;
}
/**
* @param password the password to set
*/
public void setPassword(String password) {
this.password = password;
}
/**
* @return the passwordConfirm
*/
public String getPasswordConfirm() {
return passwordConfirm;
}
/**
* @param passwordConfirm the passwordConfirm to set
*/
public void setPasswordConfirm(String passwordConfirm) {
this.passwordConfirm = passwordConfirm;
}
/**
* @return the firstName
*/
public String getFirstName() {
return firstName;
}
/**
* @param firstName the firstName to set
*/
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
* @return the lastName
*/
public String getLastName() {
return lastName;
}
/**
* @param lastName the lastName to set
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
* @return the organization
*/
public String getOrganization() {
return organization;
}
/**
* @param organization the organization to set
*/
public void setOrganization(String organization) {
this.organization = organization;
}
public boolean passwordWasModified() {
return this.passwordPlaceholderValue.equals(this.getPassword());
}
}