Flex and SSH Integration

Source: Internet
Author: User

Flex and SSH integration .- .- -  One:xx: $| Category: Flex | report |Font size subscription flex with SSH integration1, download blazeds_bin_3-0-0-544. zip package, unzip it to remove Blazeds.war package and change to Blazeds.rar, and unzip2The web-inf/lib/that you unzipped in the previous stepunder the package copy to the project Lib3, copy the Flex folder to the project's web-inf under4Copy the file under classes to SRC under Project 5 Add in Web. XML<!--Flex--<servlet> <servlet-name>flex</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value >/WEB-INF/classes/flex-application-config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>flex</servlet-name> &L T;url-pattern>/ssh/*</url-pattern> </servlet-mapping> <!--end Flex-->6, build a flex-application-config.xml file under SRC to join <?xml version= "1.0" encoding= "UTF-8"?> <beans xmlns= "Http://www.springframework.org/schema/beans"xmlns:flex="Http://www.springframework.org/schema/flex"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation="Http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd   Http://www.springframework.org/schema/flex   http://www.springframework.org/schema/flex/spring-flex-1.0.xsd"> <flex:message-broker/> <!-Below is a bean--><flex:remoting-destination ref= that is configured in the Spring configuration file" Flowserver "/></beans> The following content 6, join flex with the package that spring relies on for flex and SSH integration--The flower falls who-zhangcb666 's blog 7 writes Java class 1> writes the class body Deptnode. Class Package Com.svse.entity.bean; Import Java.util.arraylist;import java.util.list;/**** Note: This class can not be mapped with Flex, because on the flex side, we do not have to strongly turn object objects into objects **/ Public classDeptnode {Private intID; PrivateString name; PrivateDeptnode Parent; Privatelist<deptnode> children =NULL;  PublicDeptnode () {} PublicDeptnode (intID, String name) {        This. ID =ID;  This. Name =name; }    /*************get and set omitted ****************/   }2> Writing interface Iflowserver.classPackage com.svse.server; import java.util.list;import com.svse.entity.bean.DeptNode; Public InterfaceIflowserver {//get the DepartmentList<deptnode> Getdeparts (intdeptid);} 3>write implementation class package com.svse.server.impl; import java.util.List; Import Com.svse.entity.bean.deptnode;import Com.svse.server.IFlowServer;  Public classFlowserver implements Iflowserver {//get the Department     PublicList<deptnode> Getdeparts (intDeptID) {List<DeptNode> list =NewArraylist<deptnode>(); Deptnode node=NewDeptnode (); Node.setid (xx); Node.setname ("parent Node"); Node.setchildren ( This. Getchild (3,"AA"));             List.add (node); Deptnode Node2=NewDeptnode (); Node2.setid ( One); Node2.setname ("parent Node"); Node2.setchildren ( This. Getchild (5,"BB"));             List.add (Node2); returnlist; }       PrivateList<deptnode> Getchild (intcount,string name) {List<DeptNode> list =NewArraylist<deptnode>();  for(inti =0; I < count; i++) {Deptnode node3=NewDeptnode ();           Node3.setid (i); Node3.setname (Name+""+i);       List.add (NODE3); }       returnlist; }     }} 8inject in spring<bean id="Flowserver" class="Com.svse.server.impl.FlowServer"/>NOTE: The ID here is the Flex-application-in config.<flex:remoting-destinationref="Flowserver"/>the configured ref value9Writing Flex Code<?xml version="1.0"encoding="Utf-8"? ><mx:application xmlns:mx="Http://www.adobe.com/2006/mxml"layout="Absolute"Creationcomplete="Init ()"> <mx:Script> <![cdata[import Mx.rpc.remoting.mxml.RemoteObject; Import Bean.           Fileaction;           Import mx.collections.ArrayCollection;           Import mx.rpc.events.FaultEvent;           Import mx.rpc.events.ResultEvent;           Import Mx.controls.Alert; /** * Request data from server **/function Loaddept ():void{              varRemote:remoteobject =NewRemoteObject (); Remote.destination="Flowserver"; Remote.endpoint="/SSH2-FLEX/MESSAGEBROKER/AMF"; Remote.getdeparts (1);              Remote.addeventlistener (Resultevent.result,resulthander1);           Remote.addeventlistener (Faultevent.fault,fault); }           /** * After the successful request, the method of the call **/function ResultHander1 (Event: resultevent):void{              //convert only to collection objects here, regardless of objects in the collection object              varList:arraycollection =Event. Result asarraycollection;  This. Deptlist.dataprovider =list; }           /** * Initialize **/function init ():void{              varXmlarray:arraycollection =Newarraycollection ([{"name":"Shanghai","selected":false,"Children":[{"name":"Huangpu","selected":false},                                                      {"name":"Pudong","selected":false}]},                     {"name":"Beijing 1","selected":false,"Children":NULL}                  ]); //the Tree object takes Chilren as a child node by defaultDeptlist.dataprovider=XmlArray; }                     /** * method to invoke after error **/function Fault (Event: faultevent):void{alert.show ("Error"); }           /** * Double click to invoke method **/function ShowMsg ():void{              varst:string = DeptList.selectedItem.id +" "+DeptList.selectedItem.name;           Alert.show (ST); }       ]]> </mx:Script> <mx:label/> <mx:HBox> <mx:button label="Loading Data"click="loaddept ()"Fontsize=" -"/> <mx:tree id="deptlist"Labelfield="name"Width=" $"height=" -"itemdoubleclick="showmsg ()"/> </mx:HBox></mx:Application>Note: Java class Plus can also return data from the XML grid for flex invocation, see Related documents

Flex and SSH Integration

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.