Ok.. i did it... its all right.. but i dont know...

i will print my code:

JSP:
<[EMAIL PROTECTED] contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!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>JSP Page</title>
    </head>
    <body>
        <s:form action="save_dadosPessoais" method="POST" theme="xhtml">
            <s:textfield name="dadosPessoais.nome" theme="xhtml"/>
            <s:textfield name="dadosPessoais.cpf" theme="xhtml"/>
            <s:textfield name="dadosPessoais.origem" theme="xhtml"/>
            <s:submit value="Enviar" theme="xhtml" />
        </s:form>
    </body>
</html>

MY STRUTS.XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Fundation//DTD Struts Configuration 2.0//EN"
    "./struts-2.0.dtd">
<struts>
    <include file="struts-default.xml" />
    <package name="default" extends="struts-default">
        <action name="save_dadosPessoais" method="create"
class="br.com.mercur.th.action.DadosPessoaisAction">
            <result>/TH_DadosPessoais.jsp</result>
        </action>
    </package>
</struts>

ACTION CLASS
public class DadosPessoaisAction
{
    private DadosPessoais dadosPessoais;
    public String create()
    {
        System.out.println("DADOS PESSOAIS");
        System.out.println(dadosPessoais.getNome());
        System.out.println(dadosPessoais.getOrigem());
        System.out.println(dadosPessoais.getCpf());

        return ActionSupport.SUCCESS;
    }

    public void setDadosPessoais(DadosPessoais dadosPessoais) {
        this.dadosPessoais = dadosPessoais;
    }
}

DadosPessoais Class:
public class DadosPessoais
{
    private String nome;
    private String origem;
    private String cpf;
    public void setNome(String nome) {
        this.nome = nome;
    }
    public String getNome() {
        return nome;
    }
    public void setOrigem(String origem) {
        this.origem = origem;
    }
    public String getOrigem() {
        return origem;
    }
    public String getCpf() {
        return cpf;
    }
    public void setCpf(String cpf) {
        this.cpf = cpf;
    }


}


On Mon, May 19, 2008 at 3:30 PM, Milan Milanovic <[EMAIL PROTECTED]>
wrote:

> Check the names of the fields, they must mach with attributes names in
> action class, and also check that you have correct get/set methods for them
> in your action class.
>
> --
> Milan
>
> Jim Kiley <[EMAIL PROTECTED]> wrote: Felipe,
>
> It would be much easier for others to help you if you would include
> relevant
> parts of your code, as well as let us know what version of Struts you are
> using.
>
> jk
>
> On Mon, May 19, 2008 at 2:15 PM, Felipe Lorenz
>  wrote:
>
> > Hi,
> >
> > i did work with struts, and im work with it. But, i dont how, the value
> of
> > field are not send to Action class.. for example:
> >
> > My forms have 3 fields.. text.. normal.. simple..
> >
> > so, when i submit this the form only the last filed are set.
> >
> > I put a System.out in my action class, and i see only the last field
> > seted..
> > the other stay NULL...
> >
> > Why?
> >
>
>
>
> --
> Jim Kiley
> Technical Consultant | Summa
> [p] 412.258.3346 [m] 412.445.1729
> http://www.summa-tech.com
>
>
>
>

Reply via email to