Chamar múltiplos métodos struts 2

2 respostas
aangreen

E ai pessoal,

Estou começando a desenvolver com struts 2 e estou com umas dúvidas...
Tenho o seguinte código em minha action

public String execute () throws Exception
    {
        EntityManager em = getEntityManager ();

        if (this.idInstituicao <= 0)
        {
            SIA siaService = new SIA ();
            this.estados = siaService.listarEstado ();
            if (this.idEstado > 0)
            {
                // carregar instituições
                this.instituicoes = new ArrayList<Instiuicao>();
                Instiuicao inst = new Instiuicao();
                inst.setIdInstituicao (1);
                inst.setNome ("Instituição Falcatrua");
                
                this.instituicoes.add (inst);
                
            } else
            {
                this.instituicoes = new ArrayList<Instiuicao> ();
            }
            
            return LOGIN;
        }
        return "index";
    }

    public String montaInstituicoes () throws Exception
    {
        SIA siaService = new SIA ();
        this.estados = siaService.listarEstado ();
        
        return LOGIN;
    }

Como faço para chamar o segundo método da action?

O xml do meu struts.xml
<action name="index" class="br.estacio.matriculas.control.IndexAction">
			<result name="index">/matriculas/index.jsp</result>
			<result name="login">/matriculas/login.jsp</result>
		</action>

estou chamando da seguinte forma http://localhost:8080/aplicacao/index.action

2 Respostas

cris.t

não se entendi a sua pergunta mas para chamar um método que não seja o execute é assim:

<action name="index!*" class="br.estacio.matriculas.control.IndexAction" method="{1}">  
                <result name="index">/matriculas/index.jsp</result>  
                <result name="login">/matriculas/login.jsp</result>  
    </action>

e no seu jsp onde vc for chamar a action por exemplo:

<s:a href "index!montaInstituicoes">
aangreen

Na verdade era isso mesmo…

Valew

Criado 20 de novembro de 2008
Ultima resposta 24 de nov. de 2008
Respostas 2
Participantes 2