about Flex DataGrid edit
Summary(¸ÅÊö)£º Adobe Flex µÄ dataGrid ÓкÜÇ¿´óµÄ¹¦ÄÜ£¬±ÈÈçItemRenderer,headerRendererµÈ£¬¿ÉÒÔ·½±ãµØʵÏÖ×Ô¼ºÏëÒªµÄ¹¦ÄÜ¡£µ«¶ÔdataGridÖ±½Ó±à¼²¢±£´æµ½Service¶Ë£¬¾ÍÓеãÂé·³ÁË¡£
Requirement(ÐèÇó)£º ¶ÔdataGrid½øÐе¥Î»¸ñ±à¼£¬ÈôÓб仯£¬±£´æµ½Service; ·ñÔò²»±£´æ¡£
Solution(½â¾ö·½°¸): ÔËÓÃDataGrid µÄ itemEditBegin ʼþ¡¢itemFocusOut ʼþ¡£
1. when the itemEditBegin is dispatched, the event handler should save this cell value as old value.(±à¼Ç°±£´æ¾ÉÖµ)
2. when the listener of itemFocusOut is responding, you should check the current cell to the old value. If it's value have changed, you should save the new value to Service.(±à¼ºóÅжϣ¬ÊÇ·ñ¸ü¸Ä¡£)
Example(Àý×Ó) as follow:
<mx:Script>
<![CDATA[
private var oldValueOfEditedItem: CreditVO;
private function creditDGEditBegin(event: DataGridEvent): void {
oldValueOfEditedItem = (event.itemRenderer.data as CreditVO).clone() as CreditVO;
}
private function editedItemChanged(newValue: CreditVO): Boolean {
return (newValue.amount != oldValueOfEditedItem.amount)||
(newValue.description != oldValueOfEditedItem.description);
}
private function creditDGEditEnd(event: DataGridEvent): void {
var newValue: CreditVO = event.itemRenderer.data as CreditVO;
if (editedItemChanged(newValue)) {
dispatchEvent(new UpdateCreditEvent(newValue))
}
}
]]>
&
Ïà¹ØÎĵµ£º
MyEclipse FlexµÄÅäÖÃÖ®³õÎÒÃÇ¿´¿´ÔµÓÉ£ºÒ»¿ªÊ¼Ñ§Ï°Ê¹ÓÃFlexµÄʱºò,ÎÒÊÇÓõĵ¥¶ÀµÄFlexBuilder3,×öЩ´¿FlexµÄÓ¦ÓóÌÐò»¹¿ÉÒÔ.µ«ÊÇÈç¹ûÒªºÍJava½áºÏÔÚÒ»ÆðʹÓÃ,¼´ÀûÓÃFLEX³äµ±Ò»¸öÍêÕûµÄJ2EEϵͳµÄWEB²ãµÄ»°,ÄÇôµ¥¶ÀʹÓÃFlexBuilder3ºÍMYECLIPSEÊǺܲ»·½±ãµÄ,´ó´óÓ°ÏìÁË¿ª·¢Ð§ÂÊ,Òò´Ë×öÁËÏÂMyEclipse+FlexµÄÅäÖÃ,´ïµ½Ö±½ÓÔÚ ......
Root folder
Õâ¸öĿ¼Ӧ¸ÃÌîдtomcatĿ¼Ï£¬ÄǸöjavaÏîÄ¿µÄËùÔÚλÖã¬Èç¹ûΪ´í£¬»á³öÏÖ“ Invalid root. The WEB-INF/flex folder must contain either flex-config.xml or services-config.xml.”ËüÌáʾ¸ÃĿ¼WEB-INF²»´æÔÚflex-config.xml»òservice-config.xmlÎļþ£¬Èç¹ûÊÇÒ»¸öÕý³£µÄjavaÏîÄ¿£¬¾Í»áÓÐÕâ¸öÎļ ......
ÓÃÁËÁ½Ììʱ¼äѧϰÁËÏÂFlexºÍjavaÅäºÏʵÏÖÎļþÉÏ´«£¬ÕÒÁ˸öСÀý×Ó¡£Ç°¶Ëµ±È»ÊÇflex£¬ºǫ́ʹÓÃservlet£¬°Ñ´úÂëÌùÉÏÀ´£¬±¸Íü°É£º
FileUpload.java:
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletExc ......
¹ØÓÚFlex»òFlashµÄ¿çÓò·ÃÎʵĽâ¾ö·½°¸£¬ÊÂÇéµÄÆðÒòÊÇ£¬ÓÉÎÒ¹«¿ªµÄÒ»¸öwebservice£¨²»Çå³þÕâ¸öwebservice¸ÉʲôµÄÇë¿´ÕâÀ¿ªÊ¼µÄ£¬kenshinµÄÅóÓÑsensunÔÚÕâ¸ö¹«¿ªµÄwebserviceµÄ»ù´¡ÉÏÖÆ×÷ÁËÒ»¸öweather²éѯµÄ£¬ÔÚ±¾»ú²âÊÔok£¬Ò»Äõ½ÍøÉÏ£¬¾Í»á³öÏÖerror£¨ÊÇ¿çÓò·ÃÎʵĴíÎ󣩣¬ºóÀ´£¬kenshinÖÕÓÚÕÒµ½ÁËÕâ¸öÎÊÌâµÄ½â¾ö·½° ......