JavaDabbaDoo.org -Tu comunidad Java parlante Implementar MVC - Struts 1.2
Inicio | Cursos infosintesis.net liberados | Java EE | Registrar a un usuario en un sitio Web con Struts 1.2
Registrar a un usuario en un sitio Web con Struts 1.2
Paso 6: Operativa

Vista - registroForm.jsp - Añadir más campos de texto al formulario

Ahora vamos a introducir cinco nuevos campos de texto en el formulario. Estos son los nombres de estos campos de texto y sus tamaños

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>

<!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>Formulario Registro usuario Struts 1.2</title>
 <link rel="stylesheet" href="/proregusuariostruts/css2/estilos.css" type="text/css">
</head>
<body>
 <html:form action="registro">
  <html:hidden property="submitRealizado" value="true" />
  <div style="left: 210px; top: 10px; font-size: 24px;
       font-weight: bold; position: absolute">
   <bean:message key="literal.registroUsurario" />
  </div>
  <div style="left: 250px; top: 40px; font-size: 10px; position: absolute">
   *<bean:message key="literal.camposRequeridos" />
  </div>

  <div style="left: 28px; top: 80px; position: absolute">
   <bean:message key="literal.nombre" />*
  </div>
  <div style="left: 28px; top: 100px; position: absolute">
   <html:text property="nombre" size="40" />
  </div>
  <div style="left: 28px; top: 123px; position: absolute">
   <html:errors property="nombre" />
  </div>

  <div style="left: 320px; top: 80px; position: absolute">
   <bean:message key="literal.apellido" />*
  </div>
  <div style="left: 320px; top: 100px; position: absolute">
   <html:text property="apellido" size="40" />
  </div>
  <div style="left: 320px; top: 123px; position: absolute">
   <html:errors property="apellido" />
  </div>


  <div style="left: 28px; top: 140px; position: absolute">
   <bean:message key
="literal.email" />*
  </div>
  
<div style="left: 28px; top: 160px; position: absolute">
   <html:text property
="email" size="40" />
  </div>
  <div style="left: 28px; top: 183px; position: absolute">

   <html:errors property="email" />
  </div>

  <div style="left: 320px; top: 140px; position: absolute">

   <bean:message key=
"literal.codigoPostal" />*
  </div>
  <div style="left: 320px; top: 160px; position: absolute">

   <html:text property
="codigoPostal" size="5" />
  </div>
  <div style="left: 320px; top: 183px; position: absolute">

   <html:errors property="codigoPostal" />
  </div>


  <div style="left: 28px; top: 200px; position: absolute">

   <bean:message key=
"literal.login" />*
  </div>
  <div style="left: 28px; top: 220px; position: absolute">

   <html:text property
="login" size="40" />
  </div>
  <div style="left: 28px; top: 243px; position: absolute">

   <html:errors property
="login" />
  </div>


  <div style="left: 28px; top: 260px; position: absolute">

   <bean:message key=
"literal.password" />*
  </div>
  <div style="left: 28px; top: 280px; position: absolute">

  <html:password property=
"password1" size="40" />
  </div>
  <div style="left: 28px; top: 303px; position: absolute">

   <html:errors property
="password1" />
  </div>

  <div style="left: 320px; top: 260px; position: absolute">

   <bean:message key=
"literal.confirmarPassword" />*
  </div>
  <div style="left: 320px; top: 280px; position: absolute">

   <html:password
property="password2" size="40" />
  </div>
  <div style="left: 320px; top: 303px; position: absolute">

   <html:errors property
="password2" />
  </div>


  <div style="left: 230px; top: 440px; position: absolute">
   <html:reset>
    <bean:message key="literal.restaurar" />
   </html:reset>
  </div>
  <div style="left: 320px; top: 440px; position: absolute">
   <html:submit>
    <bean:message key="literal.enviar" />
   </html:submit>
  </div>
 </html:form>
</body>
</html>

En el fichero literales/ApplicationResource.properties añadimos las llaves

literal.registroUsurario=Registro de usuario
literal.camposRequeridos=Campos requeridos

literal.nombre=Nombre
literal.apellido=Apellido
literal.email=E-Mail
literal.codigoPostal=Código Postal
literal.login=Login
literal.password=Password
literal.confirmarPassword=Confirmar Password

literal.enviar=Enviar
literal.restaurar=Restaurar

error.nombre.requerido=Nombre obligatorio
error.apellido.requerido=Apellido obligatorio
error.email.requerido=Email obligatorio
error.email.incorrecto=Email incorrecto
error.codigoPostal.requerido=Código postal obligatorio
error.codigoPostal.incorrecto=Código postal incorrecto
error.login.requerido=Login obligatorio
error.password.requerido=Password obligatorio
error.password.incorrecto=Longitud mínimo 8 carcateres
error.confirmarPassword.requerido=Confirmar password obligatorio
error.confirmarPassword.incorrecto=Los dos passwords no coinciden

errors.header=
errors.prefix=<span style="font-size: 10px; color: red" >
errors.suffix=</span>
errors.footer=

Página anterior
Ignasi Pérez Valls
Infosintesis Solutions Group


Junio 2009
JavaDabbaDoo.org
Tu comunidad Java parlante. Cursos abiertos, tutoriales y mucho mucho más ...