20080402 public ããããã£å¯¾å¿ã«ã¤ãã¦è¿½è¨
ActionScript ã«å°ãæ £ãã¦ããã®ã§ S2Flex2 - AMF3Gateway with DI Container - ã§ãµã¼ãã¼å´ã¨ã®é£æºããã£ã¦ã¿ããã¹ãã
åæ
ã¨ããããä¸è¨ã®ãããã¯ãã¯å ã«å ¥ãã¦ããã
ç°å¢æ§ç¯
blog ãªã©ãè¦ã¦ãã¨ãDolteng 㧠S2Flex2 ã®ããã¸ã§ã¯ããçéä½æï¼ãã¨ã®ãã¨ãªã®ã§ãã¾ã Dolteng ãå ¥ãããS2Flex2 Blank プロジェクト ãªãã¦ã®ããããã©æ°ã«ãã¦ã¯ãããªãã
Eclipse ã®ãã«ã -> ã½ããã¦ã§ã¢æ´æ° -> æ¤ç´¢ããã³ã¤ã³ã¹ãã¼ã« ã§ãã¤ã³ã¹ãã¼ã«ããæ°è¦ãã£ã¼ãã£ã¼ãæ¤ç´¢ããé¸æãã¦ã次ã¸ãããæ°è¦ãªã¢ã¼ãã»ãµã¤ãã㧠URL ã« http://eclipse.seasar.org/updates/3.2/ ãå ¥ãããååã¯ä»»æãå ¥åãä»ä½ã£ããµã¤ãã«ãã§ãã¯ãã¤ãã¦ããã®ã確èªãã¦ãçµäºãããã¤ã³ã¹ãã¼ã«ãããã£ã¼ãã£ã¼ã®é¸æããã Dolteng ã«ãã§ãã¯ãå ¥ãã¦ã次ã¸ãããã¨ã¯ç»é¢ã®æ示ã©ãããããã°ã¤ã³ã¹ãã¼ã«å®äºã
S2Flex2 ããã¸ã§ã¯ãã®ä½æ
ãã¡ã¤ã« -> æ°è¦ -> ããã¸ã§ã¯ã -> Chura ããã¸ã§ã¯ããé¸æãããã¸ã§ã¯ãåãåºæ¬è¨å®ã®ã«ã¼ãã»ããã±ã¼ã¸åã«ä»»æã®ååãå ¥åãããã¸ã§ã¯ãã»ã¿ã¤ãã S2Flex2 + S2Dao ãé¸æããçµäºã
ã¡ãªã¿ã«ããã¸ã§ã¯ãå㯠s2flex2test ã«ã¼ãã»ããã±ã¼ã¸å㯠testroot ã«ãã¦ããã
ããã§å ´åã«ãã£ã¦ã¯ãFlex SDK ã®ãã¼ã¸ã§ã³ã®é¸æãã¨ãããã¤ã¢ãã°ãåºãããããã©ã«ãã® SDK ã使ç¨ãã(ç¾å¨ã¯ "Flex 3") ã®ã§ OK æ¼ãã
ãããã¸ã§ã¯ãã®ãã¼ãä¸ã«ã¨ã©ã¼ãçºçãã¾ãããã¨ããããã¸ã§ã¯ãããããã£ãã¡ã¤ã«ãèªã¿åããã¨ãã§ãã¾ããã§ããããã¿ãããªã¨ã©ã¼ãåºãå ´å㯠Eclipse ãåèµ·åããã20080401 æç¹ã§ã¯ Doltengï¼ããã㯠S2Flex2 + S2Dao ã®ããã¸ã§ã¯ãã¿ã¤ããï¼ï¼ ãããã§ã¼ã« Eclipse 3.3 ã«å¯¾å¿ãããããEclipse ã®ããã¸ã§ã¯ããã¡ã¤ã«ãä¸æãä½ãã¦ãªãããããªãããã¨äºæ³ãåèµ·åããã¨ã¨ã©ã¼ã§ãªããªãããã大ãã¦åé¡ãããªããã
ããã¾ã§ãããããã¸ã§ã¯ããä¸åãã«ãããã
ããã¸ã§ã¯ããå³ã¯ãªã㯠-> Tomcat ããã¸ã§ã¯ã -> ã³ã³ããã¹ãå®ç¾©ãæ´æ°ããã
ãã®ç¶æ 㧠Tomcat ãèµ·åããAlt+Shift+D,F 㧠Flex ããããã°èµ·åãã¦ãã©ã¦ã¶ãç«ã¡ä¸ããããã¹ãã
ãèµ·åã«å¤±æãã¾ãããã¨ã©ã¼ãåºã¦ãããã°ã¢ã¼ã㧠Flex ãèµ·åããªãå ´åãããã¸ã§ã¯ãå³ã¯ãªã㯠-> ãããã㣠-> Flex ã³ã³ãã¤ã© -> HTML ã©ããã¼ã®å¿ è¦ãª Flash Player ãã¼ã¸ã§ã³ã 9.0.0 ãã 9.0.28 ï¼Flex 3 ã®å ´åï¼ã«ãããããå¤ããªãã¦ãåãå ´åããã£ãããããããããããããè¨å®æã« Flex ããã¸ã§ã¯ãã®ã¢ãããã¼ãè¦åãåºããã©ç¡è¦ããã
èµ·åã«æåããã¨ãã©ã¦ã¶ã« Hello World !! ã表示ããããã¨ã確èªããã
ããã§ããã¸ã§ã¯ãã®ä½æã¯å®äºã
ãµã³ãã«ä½æ
S2Flex2 Example S2Flex2-1.1.0対応 ã®è¶³ãç®ãµã³ãã«ã¬ãã«ã®ãã®ãåãããããã«ãªãã¾ã§ã®æé ã«ã¤ãã¦ã
ä½ææé ã«ã¤ãã¦ã¯ Flex入門 ã Flex User Group - Dolteng 0.17.0 (S2Flex2+S2Dao)でのFlex2-Java連携サンプル ãåèã«ããã
Flex éçºããã¸ã§ã¯ããã¼ã¹ãã¯ãã£ã㧠ããã¸ã§ã¯ãå³ã¯ãªã㯠-> æ°è¦ -> MXML ã³ã³ãã¼ãã³ã -> Child.mxml ãä½æãmxml ã®ååã¯ä»»æã
Child.mxml ã®ä¸èº«ãä½ããã¨ãããããããã¼ã«ãã¨ããã S2Flex2 Example S2Flex2-1.1.0対応 ã®ä¸¸ã³ãã
Main.mxml ã®ãã¶ã¤ã³ãã¥ã¼ãéããã³ã³ãã¼ãã³ã -> ã«ã¹ã¿ã ã«å ã»ã©ä½æãã Child ã³ã³ãã¼ãã³ããããã®ã§ãããã Main.mxml ã«è²¼ãä»ãããè²¼ãä»ãããã£ã¦ã®ã¯ Button ã¨ã Grid ã¨ãã¿ããã«ãã«ã¹ã¿ã ã«ãã Child ãè²¼ãä»ããã£ã¦æå³ã
次㫠Java å´ã®ãµã¼ãã¹ãä½æãããFlex å´ããã¯ãã® interface ã«æ¸ããããµã¼ãã¹ãå¼ã³åºããã¨ã«ãªãã
Child.mxml ãå³ã¯ãªã㯠- > Dolteng -> ãµã¼ãã¹ã®ä½æâçµäºãtestroot.web.s2flex2test.ChildService 㨠testroot.web.s2flex2test.impl.ChildServiceImpl ãèªåçæããããé¸æãã *.mxml ã«å¯¾å¿ãããµã¼ãã¹ãä½ãããã®ã§ãµã¼ãã¹ã®ã¤ã³ã¿ãã§ã¼ã¹åã¯ã[mxml å + Service] ã«ãªã£ã¦ããã
次㫠Dto ãä½æããããã®ã¯ã©ã¹ã Java 㨠Flex éã§ããã¨ãããããã¼ã¿ãªãã¸ã§ã¯ãã«ãªããããã¯èªåã§ä½ããDB é£æºãããå ´åã¯ä»ãã¼ã«ã§èªåçæãããã¨ã«ãªãã¨æãã
Java ãã¼ã¹ãã¯ãã£ã㧠WEB-INF/src/main/java ã®ã½ã¼ã¹ã»ãã©ã«ãã¼ã® testroot/dto 以ä¸ã« AddDto ã¯ã©ã¹ãä½æãããã¯ã©ã¹åã¯ä»»æã ãã© [ä»»æ + Dto] ã¨ããååã«ããå¿ è¦ããããã¯ã©ã¹ä½ææãå®è£ ã¤ã³ã¿ãã§ã¼ã¹ã« Serializable ã追å ãã¯ã©ã¹ä½æå¾ Ctrl+1 ã¨ãã§ãããã¼ãª serialVersionUID ãå ¥ãã¦è¦åãæ¶ãã¨ããã»ããããã¨æãã
AddDto ã®ä¸èº«ã¯ãããªæãã® public ããããã£ã§æ§æããããã¡ã¤ã«ã«ãããä¾ã«ãã£ã¦ãµã³ãã«ã®ä¸¸ã³ããgetter/setter ã¯ä»ã¯ä½ããªãã
public int arg1;
public int arg2;
public int sum;
次㫠Java å´ã®ãµã¼ãã¹ã®å®è£ ãè¡ãã
testroot.web.s2flex2test.ChildService ã«âã追å ãä¾ã«ãã£ã¦ãµã³ãã«ã®ï¼ï½ï½
public AddDto calculate(AddDto addDto);
testroot.web.s2flex2test.impl.ChildServiceImpl ã«âã追å ã
public AddDto calculate(AddDto addDto) {
addDto.sum = addDto.arg1 + addDto.arg2;
return addDto;
}
次㫠Flex å´ã® Java ã¨é£æºããé¨åã®ä½æãè¡ãã
ã¾ã AddDto ã¯ã©ã¹ã«å¯¾å¿ãã ActionScript ã®ã¯ã©ã¹ãä½æããã
AddDto.java ãå³ã¯ãªã㯠-> Dolteng -> æ°è¦ AS Dto ã®ä½æãSelect Action Script Folder 㧠s2flex2test ãé¸æãs2flex2test ã¯ããã¸ã§ã¯ãåãs2flex2test/testroot/web/dto/AddDto.as ãèªåçæãããããã³ã㯠ActionScript ç¨ã«åã£ãã½ã¼ã¹ãã£ã¬ã¯ããªãæå®ããæ¹ããããã ãããã©ãã¡ã³ãã¤ã®ã§ mxml ãç½®ãã¦ãããã£ã¬ã¯ããªãæå®ããã
次㫠mxml ã« S2Flex2 Service ã®ã³ã¼ããåãè¾¼ãã
Child.mxml ãéãã¦ç©ºç½è¡ã«ã«ã¼ã½ã«ãç½®ããããã¯ã«ã¼ã½ã«ä½ç½®ã«ã¿ã°ãåãè¾¼ã¾ããããã®æªç½®ãChild.mxml ãå³ã¯ãªã㯠-> Dolteng -> S2Flex2 ãµã¼ãã¹ã®è¿½å ãChildService ãå ¥åã»é¸æãããããã§âã®ãã㪠Flex-Java ééä¿¡ç¨ã®ã¿ã°ãåãè¾¼ã¾ããã
ããã§åãè¾¼ãã é£æºãµã¼ãã¹ã®ã¿ã°ãèµ·åããããã©ãã確èªããã
ããã¸ã§ã¯ãããã«ããTomcat ãèµ·åã㦠Flex ãèµ·åããã
ããã¨ãâãªæãã®ã¨ã©ã¼ãåºããããããªãã
param count mismatch
virt params=3 optional=1 mx.rpc::AbstractService/setRemoteCredentials()
over params=2 optional=0 mx.rpc::AbstractService/setRemoteCredentials()param count mismatch
virt params=3 optional=1 mx.rpc::AbstractService/setCredentials()
over params=2 optional=0 mx.rpc::AbstractService/setCredentials()
VerifyError: Error #1053: org.seasar.flex2.rpc.remoting.S2Flex2Service ã® S2Flex2Service ã®ãªã¼ãã¼ã©ã¤ããç¡å¹ã§ãã
ãã®ç¾è±¡ã¨è§£æ±ºæ³ã«ã¤ãã¦ã¯ http://ml.seasar.org/archives/seasar-user/2008-March/013214.html ã«å ±åããã¦ããã
> > ã¨ã©ã¼ãè¦ãéããFlex3ã§ä½æããã¦ããããã«æãã¾ãã
> > ãã£ã¦ãã¾ãã§ããããã
>
> 確ãã«Flex3ã§ä½æããã¦ãããã§ãã
>
> > s2flex2-tutorial/WEB-INF/lib/swc以ä¸ã®s2flex2-components.swcã
>
> >
> http://s2flex2.sandbox.seasar.org/download/2007-12-28/S2Flex2-components-2.0.0-Beta1.zip
>
> > ã®ãã®ã¨å ¥ãæ¿ãã¦ã¿ã¦ããã ãã¾ãã§ãããããhttp://ml.seasar.org/archives/seasar-user/2008-March/013214.htm ããæç²
æ示éã s2flex2test/WEB-INF/lib/swc/s2flex2-components.swc ã http://s2flex2.sandbox.seasar.org/download/2007-12-28/S2Flex2-components-2.0.0-Beta1.zip ä¸ã® s2flex2-components/target/swc/s2flex2-components.swc ã¨ç½®ãæãããç½®ãæããå¾ããã«ããã¦ã念ã®ãã Tomcat åèµ·åãããã§ãã£ãã®ã¨ã©ã¼ã¯åºãªããªãã¯ãã
ãã¶ãã ãã© Dolteng ãèªåã§å ¥ãã¦ããã s2flex2-components.swc 㯠Flex2 ã® AMF ä»æ§ã«å¯¾å¿ãããã®ã ãããããªã¨ã©ã¼ãåºãã£ã½ãããªã®ã§ Flex 3 ç¨ã®ãã¡ã¤ã«ã«å ¥ãæ¿ããã¦ããå¿ è¦ãããã¿ãããFlex 3 ã®æ£å¼çãåºããããã®ãã¡ s2flex2-components ã® beta ãåããã®ããªãããã㯠S2Flex3 ããªãªã¼ã¹ãããã®ããªã
次㫠mxml ã«å¯¾å¿ãã ActionScript ãã¼ã¸ ãçæããã
Child.mxml å³ã¯ãªã㯠-> Dolteng-> ActionScript ãã¼ã¸ã®ä½æãSelect ActionScript Dto Class ... 㧠AddDto.as ãé¸æããããã㧠Child.mxml ã«âã®ãããªã¿ã°ãåãè¾¼ã¾ããã
åæã« Child.mxml ã«å¯¾å¿ãã ChildPage.as ãä½æããããããã« Flex ãã Java ã®ãµã¼ãã¹ãå¼ã³åºãã³ã¼ããæ¸ãã
Child.mxml ã® S2Flex2Service ã« ChildPage ã®ãã³ãã©ãè¨å®ããã³ã¼ãã追å ããã
Child.mxml ã®ãã¿ã³ã® click ã«ãã³ãã©ã追å ããã
ChildPage.as ããããã¼ã«å®è£ ããã
ããã§å®è¡ããã¨ä¸è¨ã®ãããªã¨ã©ã¼ãåºãã
public function calculate():void {
var addDto:AddDto = new AddDto();
addDto.arg1=int(document.arg1_txt.text);
addDto.arg2=int(document.arg2_txt.text);
remoteCall(service.calculate(addDto), calculateOnSuccess, calculateOnFault);
}
public function calculateOnSuccess(e:ResultEvent, token:Object=null):void {
var retObj:AddDto = e.result as AddDto;
document.ans_text.text=retObj.sum.toString();
document.hoge.text=retObj.hoge.toString();
}
Error: Error #2030: ãã¡ã¤ã«ã®çµç«¯ (EOF) ãæ¤åºããã¾ããã
対å¦ã¯ S2Flex2の導入,その2 - Paradigm Shift Design ã«ããããã« *Dto ã« getter/setter ãå®ç¾©ãããpublic ããããã£ã§ãï½ãã£ã¦æ¸ãã¦ããã¨ãããã£ããã©ãã¡ã¿ãããpublic ããããã£ããã³ãã¼ã«ä¸æãåããªãã®ããS2 ã®è¨å®ã足ããªãã®ãã¯ããããããªãã
public ããããã£å¯¾å¿ã«ã¤ãã¦ã
> > S2Flex2ã¯publicãã£ã¼ã«ãã«å¯¾å¿ãã¦ããã
> > ã©ãããæãã¦é ããªãã§ããããï¼
>
> 確èªããã¨ãããç¾å¨ã®ã¨ãã対å¿ãã¦ããªãããã§ãã
(ä¸ç¥)
ã³ããããã¦ãã¾ãã®ã§ãSNAPSHOTãåå¾ãã¦ããã ããã¨
確èªã§ãããã¨æ³ãã¾ããhttp://ml.seasar.org/archives/akabana-user/2008-January/000168.html
ã¨ã®ãã¨ã
ããã§è¶³ãç®ãåãããã«ãªãã¯ãã