远程对象弹性不起作用

时间:2011-02-08 00:56:20

标签: java flex spring blazeds remoteobject

我正在使用运行在jboss-5.1.0.GA上的Flex 4 + Spring Blazeds Integration 1.5 + Spring 3.0.5 + Hibernate构建应用程序。我创建了一个简单的登录表单,当通过远程对象提交字符串时,它工作正常。但是当尝试使用Object时,它的简单不起作用。有趣的是,它甚至没有显示一个放置的警报!此外,如果我删除标签“RemoteClass”它发送到java但发生错误。贝娄是代码和配置。

我的java课程:

package com.controlefinanceiro.entities;

// imports 

@Entity
@Table(name="CF_USER_SISTEMA")
public class UserSistema implements Serializable{
    private static final long serialVersionUID = 1L;

    @Id
    @Column(name="USERNAME")
    private String username;

    @Column(name="PASSWORD")
    private String password;

    /**
     * Constructor
     */
    public UserSistema(){
    }

    // all getters and setters 
}

我的弹性课程:

package com.controlefinanceiro.view.model
{
    [Bindable]
    [RemoteClass=(alias="com.controlefinanceiro.entities.UserSistema")]
    public class UserSistema
    {
        public var username:String;
        public var password:String;
    }
}

服务-配置:

<services-config>
    <services>
        <service-include file-path="remoting-config.xml" />
    </services>

    <!-- Spring factory registration -->
    <factories>
        <factory id="spring"
            class="com.controlefinanceiro.controller.SpringFactory" />
    </factories>

    <channels>
        <channel-definition id="channel-amf"
            class="mx.messaging.channels.AMFChannel">
            <endpoint
                url="http://localhost:8080/ControleFinanceiroServices/messagebroker/amf"
                class="flex.messaging.endpoints.AMFEndpoint" />
            <properties>
                <polling-enabled>false</polling-enabled>
            </properties>
        </channel-definition>
    </channels>

      // rest of config (log, redeploy)
</services-config>

远程-配置:     

    <adapters>
        <adapter-definition id="java-object"
            class="flex.messaging.services.remoting.adapters.JavaAdapter"
            default="true" />
    </adapters>

    <default-channels>
        <channel ref="channel-amf" />
    </default-channels>

    <destination id="loginService">
        <properties>
            <factory>spring</factory>
            <source>loginService</source>
        </properties>
    </destination>
</service>

Flex应用程序:

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"  
                xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx"
               xmlns:comp="com.controlefinanceiro.view.componentes.*">
    <s:layout><s:BasicLayout/></s:layout>
    <fx:Declarations>
        <s:RemoteObject id="ro" destination="loginService" showBusyCursor="true" fault="onRemoteFault(event)"/>
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            public function doLogin(event:MouseEvent):void{
                Alert.show("login");
                var usu:UserSistema = new UserSistema();
                Alert.show("user");
                //usu.username = user.text;
                //usu.password = senha.text;
                //ro.doLogin.addEventListener(ResultEvent.RESULT,onLoginSuccess);
                //ro.doLogin.addEventListener(FaultEvent.FAULT,onLoginFault);
                //ro.doLogin(usu);
            }
            public function doEcho(event:MouseEvent):void{
                Alert.show("echo");
                ro.echo.addEventListener(ResultEvent.RESULT,alertResult);
                ro.echo.addEventListener(FaultEvent.FAULT,onLoginFault);
                ro.echo(user.text);
            }
            // others methods that just do an Alert.show()
        ]]>
    </fx:Script>
    <mx:Canvas width="242" height="141" horizontalCenter="0" verticalCenter="0">
        <s:Label id="msg" x="10" y="6"/>
        <s:Label x="21" y="37" text="Usuario:"/>
        <s:TextInput id="user" width="134" x="77" y="27"/>
        <s:Label x="30" y="67" text="Senha:"/>
        <s:TextInput id="senha" width="133" displayAsPassword="true" x="78" y="57"/>
        <s:Button label="Login" click="doLogin(event)" id="login" x="165" y="100"/>
        <s:Button x="113" y="100" label="Echo" click="doEcho(event)"/>
    </mx:Canvas>
</s:Application>

PS:对于可怜的英语和代码中的“葡萄牙语”字样抱歉:P

谢谢! 安德烈

1 个答案:

答案 0 :(得分:0)

一目了然,您的bean和XML配置似乎是正确的。

我注意到你的MXML文件中缺少alertResult事件,这可能就是为什么bean没有在flex端显示的原因!

尝试将其添加到MXML文件中:

private function alertResult(event:ResultEvent):void
{
    userSistema:UserSistema = new UserSistema();
    userSistema = (UserSistema)event.result;

    Alert.show(userSistema.username, userSistema.password);
}
  • 我也是巴西人!