1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
| <%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>test menu</title>
</head>
<body>
<html:form action="operations" focus="reference">
<table>
<tr>
<td>
<bean:message key="libelle.reference"/> :
</td>
<td>
<html:text property="reference"/>
</td>
<td>
<bean:message key="libelle.quantite"/> :
</td>
<td>
<html:text property="quantite"/>
</td>
<td>
<bean:message key="libelle.montant"/> :
</td>
<td>
<html:text property="montant"/>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<html:submit property="operation" value="ajouter" />
<html:submit property="operation" value="modifier" />
<html:submit property="operation" value="supprimer" />
</td>
</tr>
</table>
<table align="center" border="0">
<thead align="center">
<th> </th>
<th><bean:message key="libelle.reference"/></th>
<th><bean:message key="libelle.quantite" /> </th>
<th><bean:message key="libelle.montant" /> </th>
</thead>
<tbody align="center">
<tr><td>
<c:forEach items="${sessionScope.liste}" var="elem">
<c:out value="${elem}"/><br/>
</c:forEach>
</td></tr>
<tr><td><bean:message key="Liste.Number" /></td><td><input type="text" align="center" value="<c:out value="${sessionscope.taille}"/>"/></td></tr>
</tbody>
</table>
</html:form>
</body>
</html>
// code de mon action
public class NewStrutsAction extends org.apache.struts.action.Action {
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
NewStrutsActionForm newStrutsActionForm = (NewStrutsActionForm)form;
if(isCancelled(request)){
return mapping.findForward(CANCEL);
}
if(securitymanager.AuthenticateUser(newStrutsActionForm.getName(),newStrutsActionForm.getPassword())){
return mapping.findForward(SUCCESS);
}
else {
ActionMessages errors = new ActionMessages();
ActionMessage error = new ActionMessage("errors.login.invalid");
errors.add("loginWrong",error);
saveErrors(request.getSession(),errors);
return mapping.getInputForward();
}
}
} |