Senhores, sou iniciante em flex e estou ha tempo sem saber que
problema esta ocorrendo.

A aplicação acessa o metodo doLogin da minha classe java, validar o
usuario e retorna um objeto Usuario, ela executa normalmente a
function doLogin, no entanto ela trava e nao chama nem a private
function loginServiceFaultHandler(event:FaultEvent) e nem a private
function onResultDoLogin(event:ResultEvent), segue abaixo as classes
que estou utilizado:

Usuario.java
package com.digows.artigos.JavaFlex.model.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.digows.artigos.JavaFlex.model.entity.Usuario;
import com.digows.artigos.JavaFlex.model.repository.UsuarioRepository;

@Service(value = "usuarioService")
@Transactional(propagation = Propagation.REQUIRED, rollbackFor =
Exception.class)
public class UsuarioServiceImpl implements UsuarioService {

        private UsuarioRepository usuarioRepository;

        @Autowired
        public void setUsuarioRepository(UsuarioRepository usuarioRepository)
{
                this.usuarioRepository = usuarioRepository;
        }

        public Usuario save(Usuario p_usuario) throws Exception {
                try {
                        this.usuarioRepository.save(p_usuario);
                        return p_usuario;
                } catch (Exception e) {
                        throw new Exception("Não foi possível salvar." + 
e.getCause());
                }
        }

        public void remove(Usuario p_usuario) throws Exception {
                try {
                        this.usuarioRepository.remove(p_usuario);
                } catch (Exception e) {
                        throw new Exception("Não foi possível excluir." + 
e.getMessage());
                }
        }

        public Usuario findById(Usuario p_usuario) throws Exception {
                try {
                        return this.usuarioRepository.findById(p_usuario);
                } catch (Exception e) {
                        throw new Exception("Não foi possível procurar pela ID."
                                        + e.getMessage());
                }
        }

        public List<Usuario> getList() throws Exception {
                try {
                        return this.usuarioRepository.getList();
                } catch (Exception e) {
                        throw new Exception("Não foi possível listar." + 
e.getMessage());
                }
        }

        public Usuario login(Usuario p_usuario) throws Exception {
                try {
                        Usuario u = usuarioRepository.login(p_usuario);
                        System.out.println("login : " + u.getLogin());
                        System.out.println("nome : " + u.getNome());
                        return u;
                } catch (Exception e) {
                        throw new Exception("Não foi possível procurar pela ID."
                                        + e.getMessage());
                }
        }

        public Usuario doLogin(String login, String senha) throws Exception {
                try {
                        Usuario u = usuarioRepository.doLogin(login, senha);
                        System.out.println("Dados do Usuário= \n " + 
u.toString());
                        return u;
                } catch (Exception e) {
                        throw new Exception("Não foi possível procurar pela ID."
                                        + e.getMessage());
                }
        }

}

Usuario.as
package com.digows.artigos.JavaFlex.view.entity
{
        
[RemoteClass(alias="com.digows.artigos.JavaFlex.model.entity.Usuario")]
        [Bindable]
        public class Usuario
        {
                public var id:Number;
                public var nome:String;
                public var login:String;
                public var senha:String;

                public function Usuario()
                {
                }

        }
}


<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml";>
        <mx:RemoteObject id="usuarioService" showBusyCursor="true"
destination="usuarioService">
                <mx:method name="doLogin" result="onResultDoLogin(event)"
fault="loginServiceFaultHandler(event)" />
        </mx:RemoteObject>
        <mx:Panel id="pnlLogin" title="SISTEMA DE AUTENTICAÇÃO E AUTORIZAÇÃO"
                width="400" height="300" horizontalAlign="center">
                <mx:Label text="wwww" x="10" y="10" id="loginTx" width="89"/>
                <mx:TextInput id="tfLogin" x="58" y="8"/>
                <mx:Label text="Senha: " x="5" y="36"/>
                <mx:TextInput id="tfSenha" x="58" y="34" 
displayAsPassword="true"/>

                <mx:Button x="84" y="64" label="Logar" click="doLogin()"/>

        </mx:Panel>

        <mx:Script>
        <![CDATA[
                import com.digows.artigos.JavaFlex.view.entity.Usuario;
                import mx.core.Application;
                import mx.rpc.events.ResultEvent;
                import mx.rpc.events.FaultEvent;
                import mx.controls.Alert;

                [Bindable]
                private var usuario:Usuario;

        public function doLogin():void
                        {
                                usuarioService.doLogin(tfLogin, tfSenha);
                                Alert.show("entrou mo doLogin " + loginTx.text);
                        }

        private function loginServiceFaultHandler(event:FaultEvent):void{
                Alert.show("entrou no loginServiceFaultHandler");
                if(event.fault.faultString == "java.lang.Exception : Não foi
possível fazer o login")
                        Alert.show("Usuário ou senha inválida", "Erro");
                else
                        Alert.show(event.fault.message, "Erro");
                }

                private function onResultDoLogin(event:ResultEvent):void {
                        loginTx.text = "seja bem vindoaaaaaa " +
Usuario(event.result).nome.toString();
                }

                private function onFault(event:FaultEvent):void{
                        Alert.show("Erro: onFault " + event.fault.message);
                }

        ]]>
        </mx:Script>

</mx:Canvas>

On 23 ago, 13:58, Kleber Gracia <[email protected]> wrote:
> Pode fazer o teste da seguinte forma, adicione este metodo em sua classe
> java e altere o seu RemoteObject para getRetorno
>
> *public* String getRetorno(){
>
> String nome =
> "Flex e BlazeDE";
>
> *return* nome;
>
> }
>
> Aqui com certeze ira retornar a String.
>
> At.
> Kleber Gracia Soares
> Equipe Galaxyz trabalhando para vocêwww.galaxyz.com.br
> Telefone: |44| 3233-2039
> Cel.: |44| 9960-0298 - Tim
> Msn: [email protected]
> Skype: kleber.gracia
> Email: [email protected]
> "Tudo posso naquele que me fortalece!" (Fl 4,13).
>
> Em 23 de agosto de 2010 14:54, Clayton <[email protected]> escreveu:
>
> > Provavelmente não há retorno do método no seu backEnd, o retorno deve ser
> > void.
> > Para executar o result do RemotObject o método do backEnd deve fornecer um
> > retorno e não pode ser void.
>
> > Em 23 de agosto de 2010 14:47, Edu <[email protected]> escreveu:
>
> > vc nao esta enviando send();
>
> >> On 23 ago, 14:43, claudemir <[email protected]> wrote:
> >> > Boa tarde
>
> >> > Estou com o seguinte problema, quando o usuario informa o login e
> >> > senha e clicar no botao logar aplicação vai no banco valida o usuario
> >> > e retorna o mesmo, no entanto a aplicação a aplicação não estar
> >> > chamando a function onResultDoLogin(). Segue abaixo o codigo:
>
> >> > <?xml version="1.0" encoding="utf-8"?>
> >> > <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml";>
> >> >         <mx:RemoteObject id="usuarioService" showBusyCursor="true"
> >> > destination="usuarioService">
> >> >                 <mx:method name="doLogin"
> >> result="onResultDoLogin(event)"
> >> > fault="loginServiceFaultHandler(event)" />
> >> >         </mx:RemoteObject>
> >> >         <mx:Panel id="pnlLogin" title="SISTEMA DE AUTENTICAÇÃO E
> >> AUTORIZAÇÃO"
> >> >                 width="400" height="300" horizontalAlign="center">
> >> >                 <mx:Label text="wwww" x="10" y="10" id="loginTx"
> >> width="89"/>
> >> >                 <mx:TextInput id="tfLogin" x="58" y="8"/>
> >> >                 <mx:Label text="Senha: " x="5" y="36"/>
> >> >                 <mx:TextInput id="tfSenha" x="58" y="34"
> >> displayAsPassword="true"/>
>
> >> >                 <mx:Button x="84" y="64" label="Logar"
> >> click="doLogin()"/>
>
> >> >         </mx:Panel>
>
> >> >         <mx:Script>
> >> >         <![CDATA[
> >> >                 import com.digows.artigos.JavaFlex.view.entity.Usuario;
> >> >                 import mx.core.Application;
> >> >                 import mx.rpc.events.ResultEvent;
> >> >                 import mx.rpc.events.FaultEvent;
> >> >                 import mx.controls.Alert;
>
> >> >                 [Bindable]
> >> >                 private var usuario:Usuario;
>
> >> >         public function doLogin():void
> >> >                         {
> >> >                                 this.usuario = new Usuario();
> >> >                                 loginTx.text = "Validando o login";
> >> >                                 usuarioService.dologin(tfLogin.text,
> >> tfSenha.text);
> >> >                                 Alert.show("entrou mo doLogin " +
> >> loginTx.text);
> >> >                         }
>
> >> >         private function
> >> loginServiceFaultHandler(event:FaultEvent):void{
> >> >                 Alert.show("entrou no loginServiceFaultHandler");
> >> >                 if(event.fault.faultString == "java.lang.Exception : Não
> >> foi
> >> > possível fazer o login.Incorrect result size: expected 1, actual 0")
> >> >                         Alert.show("Usuário ou senha inválida", "Erro");
> >> >                 else
> >> >                         Alert.show(event.fault.message, "Erro");
> >> >                 }
>
> >> >                 private function onResultDoLogin(event:ResultEvent):void
> >> {
> >> >                         loginTx.text = "seja bem vindo " +
> >> Usuario(event.result).nome;
> >> >                         //      getList();
> >> >                         //loginTx.text = "entrou no onResultDoLogin";
> >> >                         //Alert.show("entrou no onResultDoLogin ");
> >> >                         //loginTx.text = "Salvo com Sucesso! Ultima ID:
> >> > "+Usuario(event.result).nome;
> >> >                         //loginTx.text = "Usuario Logado";
> >> >                         //Application.application.usuario=
> >> (Usuario)(event.result);
> >> >                         //tfLogin.text = "logado";
> >> >                         //tfSenha.text = "logado";
> >> >                         //Alert.show("Usuário Logado: " +
> >> > Application.application.usuario.usu_login + "\n Senha: " +
> >> >                         //Application.application.usuario.usu_senha +
> >> "\n Nome: " +
> >> > Application.application.usuario.usu_nome + "\n Cargo: " +
> >> > Application.application.usuario.usu_cargo);
> >> >                 }
>
> >> >                 private function onFault(event:FaultEvent):void{
> >> >                         Alert.show("Erro: onFault " +
> >> event.fault.message);
> >> >                 }
>
> >> >         ]]>
> >> >         </mx:Script>
>
> >> > </mx:Canvas>
>
> >> --
> >> Você recebeu esta mensagem porque está inscrito na lista "flexdev"
> >> Para enviar uma mensagem, envie um e-mail para [email protected]
> >> Para sair da lista, envie um email em branco para
> >> [email protected]
> >> Mais opções estão disponíveis emhttp://groups.google.com/group/flexdev
>
> > --
> > Clayton Marques Pereira
>
> > --
> > Você recebeu esta mensagem porque está inscrito na lista "flexdev"
> > Para enviar uma mensagem, envie um e-mail para [email protected]
> > Para sair da lista, envie um email em branco para
> > [email protected]
> > Mais opções estão disponíveis emhttp://groups.google.com/group/flexdev

-- 
Você recebeu esta mensagem porque está inscrito na lista "flexdev"
Para enviar uma mensagem, envie um e-mail para [email protected]
Para sair da lista, envie um email em branco para 
[email protected]
Mais opções estão disponíveis em http://groups.google.com/group/flexdev

Responder a