版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、準備:我個人開發(fā)時的配置:MYSQL:JDK:j2sdk-.0TOMCAT:ECLIPSE:eclipse-MYECLIPSE插件:Flex:BLEAZEDS:BlazeDS Flex 3 SDK,還包含blazeds.war、ds-console.war和samples.war,建議初學(xué)者使用;Binary Distribution版只包括blazeds.war,此為最簡配置;而Source則包含blazeds的Java源代碼,想做二次開發(fā)就下載這個。安裝:一:安裝mysql,jdk,tomcat,eclipse,myeclipse并正確配置環(huán)境變量。二:安裝flex31. 首先下載安裝Ec
2、lipse 3.3 解壓到 D:Program Fileseclipse 到算安裝成功了.2.1. 指定 Flex Builder 3.0 安裝路徑為D:Program FileseclipseFlex Builder,進下一步. (你也可設(shè)為其它目錄,但不要這樣:D:Program Fileseclipse)2. 指定 Eclipse 安裝路徑為 D:Program Fileseclipse 進下一步.3. 選擇是否安裝瀏覽器 Flash Plyer 9 插件(可選安裝)安裝要花一點時間.大家慢慢等待.出現(xiàn)一些提示你不用管它.等安裝完后運行 Eclipse.exe 你是看不到 Flex的.往
3、下看我會幫你解決這個問題_3. 綠化Flex Builder 這是重點.復(fù)制到 D:Program Fileseclipse (如果你的eclipse目錄已經(jīng)有一個site.xml 你只要把兩個文件的feature節(jié)內(nèi)容合并就好了.)2. 把D:Program FileseclipseFlex Buildereclipse下的 plugins、features(如果有的話,這是Eclipse的一些更新)復(fù)制到 D:Program Fileseclipse3. 把D:Program FileseclipseFlex Buildersdks 復(fù)制到D:Program FileseclipseOK,
4、Flex Builder安裝完成,接下來就是啟動Elipse我們現(xiàn)在已經(jīng)可以找到Flex了.但還沒完,請往下看.4. 進行Flex的配置.在Eclipse中.點擊->Window->Preferences->Flex->Installed Flex SDKs修改Flex SDKs 2.0 和 Flex SDKs 3.0的路徑點Apply讓設(shè)置成效.重啟Eclipse.你就可以開發(fā)Flex了.5. 現(xiàn)在你的Flex已經(jīng)開始工作了.但之前安裝的Flex Builder怎么辦呢.哈哈.運行這個D:Program FileseclipseFlex BuilderUninstal
5、l Adobe Flex Builder 3 Plug-inUninstall Adobe Flex Builder 3 Plug-in.exe就可以了.三:bleazeds解壓到任何一個地方就可以,主要用到里面的flex文件夾和lib文件夾HELLO WORLD示例:1. 建立數(shù)據(jù)表CREATE TABLE user ( UserID int(11) NOT NULL auto_increment, UserName varchar(20) default NULL, Password varchar(20) default NULL, Email varchar(20) default N
6、ULL, PRIMARY KEY (UserID) ENGINE=InnoDB DEFAULT CHARSET=gb2312;2. 插入測試數(shù)據(jù)3. 搭配flex+bleazeds的web項目MyFirstFSH按NEXT進入下一步點擊FINISH2.添加bleazeds支持1.找到已解壓的 bleazeds 文件夾,進入到:blazedsWEB-INF復(fù)制flex和lib兩個文件夾到MyFirstFSH下的webRoot/WEB-INF目錄下2.在web.xml文件中添加代碼:<!- Http Flex Session attribute and binding listener su
7、pport -><listener><listener-class></listener-class></listener><!- MessageBroker Servlet -><servlet><servlet-name>MessageBrokerServlet</servlet-name><servlet-class></servlet-class><init-param><param-name></param-name><
8、;param-value></param-value></init-param><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>MessageBrokerServlet</servlet-name><url-pattern>/messagebroker/*</url-pattern></servlet-mapping>將web工程添加到tomcat中按3
9、.添加flex工程 1.右鍵MyFirtstFSH,選擇:Flex Project Nature-Add Flex Project Nature注:選擇J2EE,作用LCDS遠程對象Root folder:選擇剛才Deploy的工程路徑Root URL:TOMCAT服務(wù)器的啟動路徑Context root :編譯后的FLEX文件保存路徑Output folder:工程 重構(gòu)后FLEX文件的輸出路徑點擊Finish完成2配置Flex 項目屬性在Flex視圖下,右鍵 properties打開項目屬性設(shè)置對話框.選擇 “Flex Build Path”,出現(xiàn)以下對話框:Output folder:工
10、程FLEX文件的輸出路徑Output folder URL:工程在TOMCAT服務(wù)器的啟動路徑選擇 “Flex Compiler”,出現(xiàn)以下對話框:選擇你當(dāng)前用的FLEX SDK(如何你前面步驟配置好的話就不會出錯了?。c擊Apply應(yīng)用選擇 “Flex Server”,出現(xiàn)以下對話框:Context root:是你的工程的根目錄點擊OK完成設(shè)置這時會出現(xiàn)錯誤提示:右鍵“錯誤”信息,Recreate 3.到了這個時候基本上已經(jīng)搭建好flex+bleazeds的web環(huán)境,現(xiàn)在來測試一下。在包中新一個類:HelloWorld,作用flex的一個遠程對象package com.wingo.myfi
11、rst.web.ro;publicclass HelloWorld publicString sayHelloTo(String name)return"Hello"+name;<destination id="Hello"><properties><source>com.wingo.</source></properties></destination>編輯FLEX應(yīng)用程序在src/ MyFirstFSH.mxml 中添加以下代碼:<?xml version="1.
12、0" encoding="utf-8"?><mx:Application xmlns:mx="" layout="absolute"><mx:RemoteObject id="say" destination="Hello"></mx:RemoteObject><mx:Button x="335" y="80" label=" Click" click="remotin
13、gSayHello(event);"/><mx:TextInput x="159" y="80" id="tiName"/><mx:Label x="109" y="82" text="name:"/><mx:Label text="" x="44" y="162" width="448" height="71" id="
14、lblView" color="#FCEE09" fontSize="20" fontWeight="bold" textDecoration="underline" fontStyle="normal"/><mx:Script><!CDATAfunction remotingSayHello(event:Event):voidvar iname:String=tiName.text;say.sayHelloTo(iname);></mx:Scrip
15、t></mx:Application>啟動tomcat 打開到了這一步,flex+bleazeds已經(jīng)完成4.加上spring1.右鍵Myeclipse-Add spring2.添加包:3.(網(wǎng)上的)package mon;import org.springframework.context.ApplicationContext;import org.springframework.web.context.support.WebApplicationContextUtils;import org.springframework.beans.BeansException;imp
16、ort org.springframework.beans.factory.NoSuchBeanDefinitionException;import flex.messaging.FactoryInstance;import flex.messaging.FlexFactory;import flex.messaging.config.ConfigMap;import flex.messaging.services.ServiceException;/*Thisinterfaceisimplementedbyfactorycomponentswhichprovide*instancestoth
17、eflexmessagingframework.Toconfigureflexdataservices*tousethisfactory,addthefollowinglinestoyourservices-*file(locatedintheWEB-INF/flexdirectoryofyourwebapplication).*<factories>*<factoryid="spring"class="flex.samples.factories.SpringFactory"/>*<
18、/factories>*Youalsomustconfigurethewebapplicationtousespringandmustcopythe*fileintoyourWEB-INF/libdirectory.Toconfigureyourappservertousespring,*youaddthefollowinglinestoyourWEB-file:*<context-param>*<param-name>contextConfigLocation</param-name>*&
19、;lt;param-value>/WEB-INF/applicationContext.xml</param-value>*</context-param>*<listener>*<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>*</listener>*Thenyouputyourspring
20、beanconfigurationinWEB-(asperthe*lineabove).Forexample:*<?xmlversion="1.0"encoding="UTF-8"?>*<!DOCTYPEbeansPUBLIC"-/SPRING/DTDBEAN/EN"-beans.dtd">*<beans>*<beanname="weatherBean"class="dev.weather.Weat
21、herService"singleton="true"/>*</beans>*Nowyouarereadytodefineadestinationinflexthatmapstothisexistingservice.*Todothisyou'daddthistoyourWEB-INF/flex/remoting-config.xml:*<destinationid="WeatherService">*<properties>*&l
22、t;factory>spring</factory>*<source>weatherBean</source>*</properties>*</destination>*authorJeffVroom*/publicclass SpringFactory implements FlexFactoryprivatestaticfinal String SOURCE = "source"/*Thismethodcanbeuse
23、dtoinitializethefactoryitself.Itiscalledwithconfiguration*parametersfromthefactorytagwhichdefinestheidofthefactory.*/publicvoid initialize(String id, ConfigMap configMap) /*Thismethodiscalledwhenweinitializethedefinitionofaninstance*whichwillbelookedupbythisfactory.Itshouldvalidatethat*theproperties
24、suppliedarevalidtodefineaninstance.*Anyvalidpropertiesusedforthisconfigurationmustbeaccessedto*avoidwarningsaboutunusedconfigurationelements.Ifyourfactory*isonlyusedforapplicationscopedcomponents,thismethodcansimply*returnafactoryinstancewhichdelegatesthecreationofthecomponent*totheFactoryInstance
25、39;slookupmethod.*/public FactoryInstance createFactoryInstance(String id, ConfigMap properties) SpringFactoryInstance instance = new SpringFactoryInstance(this, id, properties); instance.setSource(properties.getPropertyAsString(SOURCE, instance.getId();return instance; / end method createFactoryIns
26、tance()/*Returnstheinstancespecifiedbythesource*andpropertiesarguments.Forthefactory,thismaymean*constructinganewinstance,optionallyregisteringitinsomeother*namespacesuchasthesessionorJNDI,andthenreturningit*oritmaymeancreatinganewinstanceandreturningit.*Thismethodiscalledforeachrequesttooperateonth
27、e*givenitembythesystemsoitshouldberelativelyefficient.*<p>*Ifyourfactorydoesnotsupportthescopeproperty,it*reportanerrorifscopeissuppliedintheproperties*forthisinstance.*/public Object lookup(FactoryInstance inst) SpringFactoryInstance factoryInstance = (SpringFactoryInstance) inst;return facto
28、ryInstance.lookup(); staticclass SpringFactoryInstance extends FactoryInstance SpringFactoryInstance(SpringFactory factory, String id, ConfigMap properties) super(factory, id, properties); public String toString() return"SpringFactory instance for id=" + getId() + " source=" + ge
29、tSource() + " scope=" + getScope(); public Object lookup() ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(flex.messaging.FlexContext.getServletConfig().getServletContext(); String beanName = getSource();try return appContext.getBean(beanName); catch (No
30、SuchBeanDefinitionException nexc) ServiceException e = new ServiceException(); String msg = "Spring service named '" + beanName + "' does not exist." e.setMessage(msg); e.setRootCause(nexc); e.setDetails(msg); e.setCode("Server.Processing");throw e; catch (Beans
31、Exception bexc) ServiceException e = new ServiceException(); String msg = "Unable to create Spring service named '" + beanName + "' " e.setMessage(msg); e.setRootCause(bexc); e.setDetails(msg); e.setCode("Server.Processing");throw e; 4.在WEB-INF/flex中的services-co
32、nfig.xml中注冊SpringFactory工廠<factories><factory id="spring" class="mon.SpringFactory" /></factories>5.在WEB-INF/<!- Backend configuration -> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicati
33、onContext.xml</param-value> </context-param><servlet> <servlet-name>SpringContextServlet</servlet-name> <servlet-class> </servlet-class> <load-on-startup>1</load-on-startup></servlet><servl
34、et> <servlet-name>SpringLog4jConfigServlet</servlet-name> <servlet-class> </servlet-class></servlet><servlet> <servlet-name>web</servlet-name> <servlet-class> </servlet
35、-class></servlet>5.添加hibernate1.添加數(shù)據(jù)源右鍵MyFirstFSH-MyEclipes-Add Hibernate點擊:Finish3.添加包:結(jié)構(gòu)如下4.刪掉jar: 5.利用myeclipse自動生成User.java,User.hbm.xml,UserDAO打開:6.7.修改中對<bean id="userDAO" class="com.wingo.myfirstfsh.dao.impl.UserDAO"><property name="sessionFactory&qu
36、ot;><ref bean="sessionFactory" /></property></bean>8.添加類代碼如下:package com.wingo.myfirstfsh.service.impl;import com.wingo.myfirstfsh.dao.impl.UserDAO;import com.wingo.myfirstfsh.vo.User;publicclass IUserServiceImpl private UserDAO userDAO;/*通過ID搜索返回一個User對象 * param id 需要
37、查找的用戶ID * return User對象 * */public User getUser(Integer id)returnuserDAO.findById(id);public UserDAO getUserDAO() returnuserDAO;publicvoid setUserDAO(UserDAO userDAO) this.userDAO = userDAO;9.代碼如下:package com.wingo.myfirstfsh.web.ro;import com.wingo.myfirstfsh.service.impl.IUserServiceImpl;import com.wingo.myfirstfsh.vo.User;publicclass HelloWorld private IUserServiceImpl userService;/* * 該方法通過用戶ID返回用戶名 * para
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 快餐攤位租賃合同
- 2024【辦公大樓的物業(yè)管理委托合同】對付物業(yè)最有效的辦法
- 技術(shù)轉(zhuǎn)讓合同注意事項
- 2024日用品采購合同范本
- 2024年戶外廣告牌設(shè)置與發(fā)布合同
- 交通事故私了協(xié)議書模板
- 期刊廣告投放區(qū)域協(xié)議
- 農(nóng)村調(diào)解協(xié)議書樣本
- 房產(chǎn)貸款合同匯編
- 2024家庭雇傭保姆合同協(xié)議書
- 微景觀制作課件
- 業(yè)務(wù)招待費審批單
- 建筑工程項目管理咨詢招標(范本)
- 三位數(shù)除兩位數(shù)的除法練習(xí)題
- 慢性胃炎的中醫(yī)治療培訓(xùn)課件
- Python程序設(shè)計課件第7章面向?qū)ο蟪绦蛟O(shè)計
- 主題班會課防盜
- 幼兒園課件《撓撓小怪物》
- 教師教案檢查八大評分標準教案的評分標準
- 政府會計基礎(chǔ)知識講義
- 幼兒園整合式主題活動設(shè)計案例《溫馨家園》
評論
0/150
提交評論