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 3: Operativa

Vista - registroForm.jsp - Añadir campos te texto nombre y apellido al formulario

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

Como podemos ver NetBeans nos ayuda a elegir los atributos de la etiqueta de Struts <html:text>. En este ejmplo vemos el javadoc del atributo property.

NetBeans 6 - Añadir etiqueta Struts <html:text>

Este es el código de la página registroForm.jsp después de añadirle los campos de texto nombre y apellido

<%@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">
  <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>

 </html:form>
</body>
</html>

En el fichero literales/ApplicationResource.properties

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

literal.nombre=Nombre
literal.apellido=Apellido

error.nombre.requerido=Nombre obligatorio
error.apellido.requerido=Apellido obligatorio

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 ...