Flex + J2EE instance (cairngorm + blazeds + hibernate + spring) Part2

Source: Internet
Author: User

1. Compile the background Java processing method:

Create a com package under the SRC File

Create a class file under COM and name it "hello"

Add processing code:

PackageCom;

 

Public classHello {

PublicString Hello (string name ){

System.Out. Println ("flex calls Java! Name = "+ name );

Return"Hello" + name;

}

}

 

2. Configure remoting-config.xml

Add code

<Destination ID ="Hello">

<Properties>

<Source>

Com. Hello

</Source>

</Properties>

</Destination>

As follows:

3. Modify the flexj2ee. mxml file under flex_src

 

<? XML version = "1.0" encoding = "UTF-8"?> <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 "minwidth =" 955 "minheight =" 600 "> <FX: declarations> <! -- Place a non-visual element (such as a service or value object) Here --> <s: remoteobject Destination = "hello" id = "hell_ro" result = "GG (Event) "endpoint =" http: // localhost: 8089/flexj2ee/messagebroker/AMF "> </S: remoteobject> </FX: declarations> <FX: SCRIPT> <! [CDATA [import MX. RPC. events. resultevent; import MX. controls. alert; Private function Gg (E: resultevent): void {var backtext: String = E. result as string; backtxt. TEXT = backtext;} protected function remotingsayhello (Event: mouseevent): void {var sname: String = nameinput. text; hell_ro.hello (sname) ;}]> </FX: SCRIPT> <s: textarea id = "backtxt" x = "109" Y = "122" Height = "99"/> <s: button label = "send" Click = "remotingsayhello (Event) "x =" 110 "Y =" 243 "/> <s: textinput id =" nameinput "x =" 109 "Y =" 73 "/> <s: label x = "47" Y = "75" text = "rieciver:"/> <s: label x = "47" Y = "36" text = "this is my first flexj2ee project. Welcome to my blog http://blog.csdn.net/kkkloveyou"/> </S: Application>

4. Open http: // localhost: 8089/flexj2ee/flex/flexj2ee.html

Enter "may" in the rieciver input box.

Click "send"

The following "Hello May" is returned, indicating that flex has successfully communicated with Java.

5. the console output is as follows:

 

Full download: http://download.csdn.net/detail/kkkloveyou/4072746

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.