You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rafael Chiarinelli <rc...@yahoo.com.br> on 2004/04/12 00:11:57 UTC

Retrieve Data from Validation

Hello for all.

    My name is Rafael and I'm new user in Struts. So, I have a doubt 
about form validation. When I have a form, and has some wrong data in 
this form, the Validator return to form with the errors. Have any way to 
return with the data int the text box, combos and others components?
    My apologies about my english.

Best Regards,

Rafael Chiarinelli


RE: Retrieve Data from Validation

Posted by David Friedman <hu...@ix.netcom.com>.
Rafael,

Something looks wrong with your select tag "perfil_usuario".  Are those item
setup to look like "option" tags such as: '<option
name="value">value</option>'? Why don't you use html:options instead so it
can auto-mark the selected one?  When you use bean:write like that, there is
nothing in your page to show it how to mark any appropriate item as the
'selected' select option.  Take a look at this url:
http://jakarta.apache.org/struts/userGuide/struts-html.html#options

Regards,
David

-----Original Message-----
From: Rafael Chiarinelli [mailto:rchiarinelli@yahoo.com.br]
Sent: Sunday, April 11, 2004 6:19 PM
To: Struts Users Mailing List
Subject: Re: Retrieve Data from Validation


David,

    Yes, I do. I'm using the Struts Taglibraries.  Here is a form example.

Regards,

Rafael

<%@ page import="java.util.*" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="pages/css/estilos.css" rel="stylesheet" type="text/css">
</head>

<logic:notPresent name="Usuario">
    <logic:forward name="login" />
</logic:notPresent>

<body>
  <table border="0" cellspacing="0" cellpadding="0" width="100%"
height="100%">
      <tr align="center" width="100%" height="100%">
        <td align="center" valign="top" width="100%" height="100%">
            <table border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td colspan="4" align="center" class="titulo2">
                        <bean:message key="cadastro.usuarios.titulo" />
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        &nbsp <br>&nbsp <br>&nbsp <br>&nbsp <br>&nbsp
<br>&nbsp <br>
                    </td>
                </tr>
                <tr >
                    <td colspan="4" class="titulo3" align="center">
                        <bean:message key="cadastro.usuarios.operacao" />
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        &nbsp <br>&nbsp <br>
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <table border="0" cellspacing="0"
cellpadding="0" width="100%" height="100%">
                            <tr>
                                <td colspan="2" align="left"
class="fontes2">
                                      <html:errors />
                                </td>
                            </tr>
                            <html:form name="cadastro_usuarios"
method="POST" action="CadastroUsuarios"
type="br.com.analisesistemas.actionform.CadastroUsuariosForm">
                            <tr>
                                <td align="center" class="fontes2">
                                    <bean:message
key="cadastro.usuarios.login" />
                                </td>
                                <td>
                                    <html:text property="login_usuario"
maxlength="30" size="30" styleClass="cxtexto" />
                                </td>
                            </tr>
                            <tr>
                                <td align="center" class="fontes2">
                                    <bean:message
key="cadastro.usuarios.senha" />
                                </td>
                                <td>
                                    <html:password
property="senha_usuario" maxlength="30" size="30" styleClass="cxtexto" />
                                </td>
                            </tr>
                            <tr>
                                <td align="center" class="fontes2">
                                    <bean:message
key="cadastro.usuarios.nome" />
                                </td>
                                <td>
                                    <html:text property="nome_usuario"
maxlength="50" size="50" styleClass="cxtexto" />
                                </td>
                            </tr>
                            <tr>
                                <td align="center" class="fontes2">
                                    <bean:message
key="cadastro.usuarios.email" />
                                </td>
                                <td>
                                    <html:text property="email_usuario"
maxlength="30" size="30" styleClass="cxtexto" />
                                </td>
                            </tr>
                            <tr>
                                <td align="center" class="fontes2">
                                    <bean:message
key="cadastro.usuarios.perfil" />
                                </td>
                                <td>
                                    <html:select
property="perfil_usuario" styleClass="cxtexto">
                                        <logic:iterate id="combo"
name="DadosCombo" >
                                            <bean:write name="combo"
filter="false" />
                                        </logic:iterate>
                                    </html:select>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">&nbsp;</td>
                            </tr>
                            <tr>
                                <td>
                                    <html:button property="botao_salvar"
styleClass="botoes"
onclick="javascript:document.cadastro_usuarios.submit()">Incluir
Usuário</html:button>
                                </td>
                                <td>
                                    <html:reset
property="botao_cancelar" styleClass="botoes">Cancelar</html:reset>
                                </td>
                            </tr>
                            </html:form>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>

  </table>
</body>
</html>

David Friedman escreveu:

>Rafael,
>
>Are you using the html:text, html:textarea and other tags?  They should
>automatically re-populate the appropriate answer.  Can you give us some
>relevant form code examples from a troublesome JSP?
>
>Regards,
>David
>
>-----Original Message-----
>From: Rafael Chiarinelli [mailto:rchiarinelli@yahoo.com.br]
>Sent: Sunday, April 11, 2004 6:12 PM
>To: Struts Users Mailing List
>Subject: Retrieve Data from Validation
>
>
>Hello for all.
>
>    My name is Rafael and I'm new user in Struts. So, I have a doubt
>about form validation. When I have a form, and has some wrong data in
>this form, the Validator return to form with the errors. Have any way to
>return with the data int the text box, combos and others components?
>    My apologies about my english.
>
>Best Regards,
>
>Rafael Chiarinelli
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Retrieve Data from Validation

Posted by Rafael Chiarinelli <rc...@yahoo.com.br>.
David,

    Yes, I do. I'm using the Struts Taglibraries.  Here is a form example.

Regards,

Rafael

<%@ page import="java.util.*" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="pages/css/estilos.css" rel="stylesheet" type="text/css">
</head>

<logic:notPresent name="Usuario">
    <logic:forward name="login" />
</logic:notPresent>

<body>
  <table border="0" cellspacing="0" cellpadding="0" width="100%" 
height="100%">
      <tr align="center" width="100%" height="100%">
        <td align="center" valign="top" width="100%" height="100%">
            <table border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td colspan="4" align="center" class="titulo2">
                        <bean:message key="cadastro.usuarios.titulo" />
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        &nbsp <br>&nbsp <br>&nbsp <br>&nbsp <br>&nbsp 
<br>&nbsp <br>
                    </td>
                </tr>
                <tr >
                    <td colspan="4" class="titulo3" align="center">
                        <bean:message key="cadastro.usuarios.operacao" />
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        &nbsp <br>&nbsp <br>
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <table border="0" cellspacing="0" 
cellpadding="0" width="100%" height="100%">
                            <tr>
                                <td colspan="2" align="left" 
class="fontes2">
                                      <html:errors />
                                </td>
                            </tr>
                            <html:form name="cadastro_usuarios" 
method="POST" action="CadastroUsuarios" 
type="br.com.analisesistemas.actionform.CadastroUsuariosForm">
                            <tr>
                                <td align="center" class="fontes2">
                                    <bean:message 
key="cadastro.usuarios.login" />
                                </td>
                                <td>
                                    <html:text property="login_usuario" 
maxlength="30" size="30" styleClass="cxtexto" />
                                </td>
                            </tr>
                            <tr>
                                <td align="center" class="fontes2">
                                    <bean:message 
key="cadastro.usuarios.senha" />
                                </td>
                                <td>
                                    <html:password 
property="senha_usuario" maxlength="30" size="30" styleClass="cxtexto" />
                                </td>
                            </tr>
                            <tr>
                                <td align="center" class="fontes2">
                                    <bean:message 
key="cadastro.usuarios.nome" />
                                </td>
                                <td>
                                    <html:text property="nome_usuario" 
maxlength="50" size="50" styleClass="cxtexto" />
                                </td>
                            </tr>
                            <tr>
                                <td align="center" class="fontes2">
                                    <bean:message 
key="cadastro.usuarios.email" />
                                </td>
                                <td>
                                    <html:text property="email_usuario" 
maxlength="30" size="30" styleClass="cxtexto" />
                                </td>
                            </tr>
                            <tr>
                                <td align="center" class="fontes2">
                                    <bean:message 
key="cadastro.usuarios.perfil" />
                                </td>
                                <td>
                                    <html:select 
property="perfil_usuario" styleClass="cxtexto">
                                        <logic:iterate id="combo" 
name="DadosCombo" >
                                            <bean:write name="combo" 
filter="false" />
                                        </logic:iterate>
                                    </html:select>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">&nbsp;</td>
                            </tr>
                            <tr>
                                <td>
                                    <html:button property="botao_salvar" 
styleClass="botoes" 
onclick="javascript:document.cadastro_usuarios.submit()">Incluir 
Usuário</html:button>
                                </td>
                                <td>
                                    <html:reset 
property="botao_cancelar" styleClass="botoes">Cancelar</html:reset>
                                </td>
                            </tr>
                            </html:form>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>

  </table>
</body>
</html>

David Friedman escreveu:

>Rafael,
>
>Are you using the html:text, html:textarea and other tags?  They should
>automatically re-populate the appropriate answer.  Can you give us some
>relevant form code examples from a troublesome JSP?
>
>Regards,
>David
>
>-----Original Message-----
>From: Rafael Chiarinelli [mailto:rchiarinelli@yahoo.com.br]
>Sent: Sunday, April 11, 2004 6:12 PM
>To: Struts Users Mailing List
>Subject: Retrieve Data from Validation
>
>
>Hello for all.
>
>    My name is Rafael and I'm new user in Struts. So, I have a doubt
>about form validation. When I have a form, and has some wrong data in
>this form, the Validator return to form with the errors. Have any way to
>return with the data int the text box, combos and others components?
>    My apologies about my english.
>
>Best Regards,
>
>Rafael Chiarinelli
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Retrieve Data from Validation

Posted by David Friedman <hu...@ix.netcom.com>.
Rafael,

Are you using the html:text, html:textarea and other tags?  They should
automatically re-populate the appropriate answer.  Can you give us some
relevant form code examples from a troublesome JSP?

Regards,
David

-----Original Message-----
From: Rafael Chiarinelli [mailto:rchiarinelli@yahoo.com.br]
Sent: Sunday, April 11, 2004 6:12 PM
To: Struts Users Mailing List
Subject: Retrieve Data from Validation


Hello for all.

    My name is Rafael and I'm new user in Struts. So, I have a doubt
about form validation. When I have a form, and has some wrong data in
this form, the Validator return to form with the errors. Have any way to
return with the data int the text box, combos and others components?
    My apologies about my english.

Best Regards,

Rafael Chiarinelli



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org