Labelx="109"y="82"text="name:
"/>
Labeltext="{say.sayHelloTo.lastResult}"x="44"y="162"width="448"height="71"id="lblView"color="#FCEE09"fontSize="20"fontWeight="bold"textDecoration="underline"fontStyle="normal"/>
Script>
[CDATA[
functionremotingSayHello(event:
Event):
void{
variname:
String=tiName.text;
say.sayHelloTo(iname);
}
]]>
Script>
Application>
启动tomcat打开http:
//localhost:
8080/MyFirstFSH/pages/MyFirstFSH.html
到了这一步,flex+bleazeds已经完成
4.加上spring
1.右键Myeclipse-Addspring
2.添加包:
mon
3.添加SpringFactory.java(网上的)
packagemon;
importorg.springframework.context.ApplicationContext;
importorg.springframework.web.context.support.WebApplicationContextUtils;
importorg.springframework.beans.BeansException;
importorg.springframework.beans.factory.NoSuchBeanDefinitionException;
importflex.messaging.FactoryInstance;
importflex.messaging.FlexFactory;
importflex.messaging.config.ConfigMap;
importflex.messaging.services.ServiceException;
/**
*Thisinterfaceisimplementedbyfactorycomponentswhichprovide
*instancestotheflexmessagingframework.Toconfigureflexdataservices
*tousethisfactory,addthefollowinglinestoyourservices-config.xml
*file(locatedintheWEB-INF/flexdirectoryofyourwebapplication).
*
*<factories>
*<factoryid="spring"class="flex.samples.factories.SpringFactory"/>
*</factories>
*
*Youalsomustconfigurethewebapplicationtousespringandmustcopythespring.jar
*fileintoyourWEB-INF/libdirectory.Toconfigureyourappservertousespring,
*youaddthefollowinglinestoyourWEB-INF/web.xmlfile:
*
*<context-param>
*<param-name>contextConfigLocation</param-name>
*<param-value>/WEB-INF/applicationContext.xml</param-value>
*</context-param>
*
*<listener>
*<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
*</listener>
*
*ThenyouputyourspringbeanconfigurationinWEB-INF/applicationContext.xml(asperthe
*lineabove).Forexample:
*
*<?
xmlversion="1.0"encoding="UTF-8"?
>
*<!
DOCTYPEbeansPUBLIC"-//SPRING//DTDBEAN//EN""http:
//www.springframework.org/dtd/spring-beans.dtd">
*
*<beans>
*<beanname="weatherBean"class="dev.weather.WeatherService"singleton="true"/>
*</beans>
*
*Nowyouarereadytodefineadestinationinflexthatmapstothisexistingservice.
*Todothisyou'daddthistoyourWEB-INF/flex/remoting-config.xml:
*
*<destinationid="WeatherService">
*<properties>
*<factory>spring</factory>
*<source>weatherBean</source>
*</properties>
*</destination>
*
*@authorJeffVroom
*/
publicclassSpringFactoryimplementsFlexFactory
{
privatestaticfinalStringSOURCE="source";
/**
*Thismethodcanbeusedtoinitializethefactoryitself.Itiscalledwithconfiguration
*parametersfromthefactorytagwhichdefinestheidofthefactory.
*/
publicvoidinitialize(Stringid,ConfigMapconfigMap){}
/**
*Thismethodiscalledwhenweinitializethedefinitionofaninstance
*whichwillbelookedupbythisfactory.Itshouldvalidatethat
*thepropertiessuppliedarevalidtodefineaninstance.
*Anyvalidpropertiesusedforthisconfigurationmustbeaccessedto
*avoidwarningsaboutunusedconfigurationelements.Ifyourfactory
*isonlyusedforapplicationscopedcomponents,thismethodcansimply
*returnafactoryinstancewhichdelegatesthecreationofthecomponent
*totheFactoryInstance'slookupmethod.
*/
publicFactoryInstancecreateFactoryInstance(Stringid,ConfigMapproperties)
{
SpringFactoryInstanceinstance=newSpringFactoryInstance(this,id,properties);
instance.setSource(properties.getPropertyAsString(SOURCE,instance.getId()));
returninstance;
}//endmethodcreateFactoryInstance()
/**
*Returnstheinstancespecifiedbythesource
*andpropertiesarguments.Forthefactory,thismaymean
*constructinganewinstance,optionallyregisteringitinsomeother
*namespacesuchasthesessionorJNDI,andthenreturningit
*oritmaymeancreatinganewinstanceandreturningit.
*Thismethodiscalledforeachrequesttooperateonthe
*givenitembythesystemsoitshouldberelativelyefficient.
*
*Ifyourfactorydoesnotsupportthescopeproperty,it
*reportanerrorifscopeissuppliedintheproperties
*forthisinstance.
*/
publicObjectlookup(FactoryInstanceinst)
{
SpringFactoryInstancefactoryInstance=(SpringFactoryInstance)inst;
returnfactoryInstance.lookup();
}
staticclassSpringFactoryInstanceextendsFactoryInstance
{
SpringFactoryInstance(SpringFactoryfactory,Stringid,ConfigMapproperties)
{
super(factory,id,properties);
}
publicStringtoString()
{
return"SpringFactoryinstanceforid="+getId()+"source="+getSource()+"scope="+getScope();
}
publicObjectlookup()
{
ApplicationContextappContext=WebApplicationContextUtils.getWebApplicationContext(flex.messaging.FlexContext.getServletConfig().getServletContext());
StringbeanName=getSource();
try
{
returnappContext.getBean(beanName);
}
catch(NoSuchBeanDe