繁体   English   中英

远程对象伸缩不起作用

[英]Remote Object flex not working

我正在使用在jboss-5.1.0.GA上运行的Flex 4 + Spring Blazeds Integration 1.5 + Spring 3.0.5 + Hibernate构建应用程序。 我创建了一个简单的登录表单,当通过远程对象提交字符串时,它可以正常工作。 但是,当尝试使用对象时,简单的方法就不起作用了。 有趣的是,它甚至没有显示警报,而没有显示! 另外,如果我删除标签“ 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-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>

附言:对于代码中的英文和“葡萄牙语”字眼不佳表示抱歉:P

谢谢!! 安德烈

乍一看,您的bean和XML配置似乎是正确的。

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

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM