¾«Í¨ Grails: ʹÓà Ajax ʵÏÖ¶à¶Ô¶à¹Øϵ
ÔÚ Web Ó¦ÓóÌÐòÖУ¬¶à¶Ô¶à£¨m:m£©¹ØϵºÜÄÑ´¦Àí¡£ÔÚ ¾«Í¨ Grails ϵÁеÄÕâÒ»ÆÚÎÄÕÂÖУ¬Scott Davis ½«ÏòÄúչʾÈçºÎÔÚ Grails Öгɹ¦ÊµÏÖ m:m ¹Øϵ¡£Á˽âÈçºÎͨ¹ý Grails ¶ÔÏó¹ØϵӳÉ䣨Grails Object Relational Mapping£¬GORM£©API ºÍºó¶ËÊý¾Ý¿â´¦Àí¶à¶Ô¶à¹Øϵ¡£Ñ§Ï°ÈçºÎʹÓà Ajax£¨Asynchronous JavaScript + XML£©Á÷Ïß»¯Óû§½çÃæ¡£
Èí¼þ¿ª·¢¾ÍÊÇʹÓôúÂëÀ´Ä£ÄâÏÖʵÊÀ½ç¡£ÀýÈ磬Êé¼®¶¼ÓÐ×÷Õߺͳö°æÉÌ¡£ÔÚ Grails Ó¦ÓóÌÐòÖУ¬ÒªÎªÃ¿¸öÔªËØ´´½¨Ò»¸öÓòÀà¡£GORM Ϊÿ¸öÀà´´½¨¶ÔÓ¦µÄÊý¾Ý¿â±í£¬´î½¨¹¦ÄÜ£¨scaffolding£©Ìṩ»ù±¾µÄ Create/Retrieve/Update/Delete (CRUD) Web ½çÃæ¡£
½ÓÏÂÀ´¶¨ÒåÕâЩÀàÖ®¼äµÄ¹Øϵ¡£Ò»¸ö³ö°æÉÌͨ³£»á³ö°æ¶à²¿Í¼Ê飬Òò´Ë³ö°æÉ̺ÍËûµÄͼÊéÖ®¼äµÄ¹Øϵ¾ÍÊÇÒ»¸ö¼òµ¥µÄÒ»¶Ô¶à£¨1:m£©¹Øϵ£ºÒ»¸ö Publisher ³ö°æ¶à¸ö Book¡£Í¨¹ýÔÚ Publisher ÀàÖмÓÈë static hasMany = [books:Book]£¬´´½¨ 1:m ¹Øϵ¡£ÔÚ Book ÀàÖзÅÈë static belongsTo = Publisher£¬¿ÉÒÔÏò¹ØϵÌí¼ÓÁíÒ»¸ö·½Ãæ —— ¼¶Áª¸üкÍɾ³ý¡£Èç¹ûɾ³ýÒ»¸ö Publisher£¬ËùÓжÔÓ¦µÄ Book Ò²»á±»É¾³ý¡£
ºÜÈÝÒ×ÔڵײãÊý¾Ý¿âÖÐÄ£Äâ 1:m ¹ØϵÐÍ¡£Ã¿¸ö±íÓÐÒ»¸öÓÃ×÷Ö÷¼üµÄ id ×ֶΡ£µ± GORM Ïò book ±íÌí¼ÓÒ»¸ö publisher_id ×Ö¶Îʱ£¬¾ÍÔÚÁ½¸ö±íÖ®¼ä½¨Á¢ÁËÒ»¸ö 1:m ¹Øϵ¡£ÔÚÇ°¶Ë£¬Grails Ò²Äܹ»ºÜºÃµØ´¦Àí 1:m ¹Øϵ¡£´´½¨Ò»¸öРBook ʱ£¬×Ô¶¯Éú³ÉµÄ£¨´î½¨¶ø³É£©HTML ±íµ¥Ìṩһ¸öÏÂÀ×éºÏ¿ò£¬½«ÄúµÄÑ¡ÔñÏÞÖÆÔÚÏÖÓÐµÄ Publisher ÁбíÖС£×Ô±¾ÏµÁÐµÄ µÚһƪÎÄÕ ÒÔÀ´£¬ÎÒÃÇÒѾչʾÁËÐí¶à 1:m ¹ØϵµÄʾÀý¡£
ÏÖÔÚÀ´¿´¿´Ò»¸öÉÔ΢¸´ÔÓһЩµÄ¹Øϵ — ¶à¶Ô¶à£¨m:m£©¹Øϵ¡£Óë Book ºÍ Publisher Ö®¼äµÄ¹ØϵÏà±È£¬Ä£Äâ Book Óë Author Ö®¼äµÄ¹ØϵҪ¸´Ôӵöࡣһ²¿Í¼Êé¿ÉÒÔÓжà¸ö×÷Õߣ¬Ò»¸ö×÷ÕßÒ²¿ÉÒÔ±àд¶à²¿Í¼Êé¡£ÕâÊÇÒ»¸öµäÐ굀 m:m ¹Øϵ¡£ÔÚÕæʵÊÀ½çÖУ¬m:m ¹ØϵºÜ³£¼û¡£Ò»¸öÈË¿ÉÒÔÓжà¸ö֧ƱÕʺţ¬Ò»¸ö֧ƱÕʺÅÒ²¿ÉÒÔÓɶà¸öÈËÀ´¹ÜÀí¡£Ò»¸ö¹ËÎÊ¿ÉÒÔΪ¶à¸öÏîÄ¿¹¤×÷£¬Ò»¸öÏîÄ¿Ò²¿ÉÒÔÓжà¸ö¹ËÎÊ¡£±¾ÎĽ«ÏòÄúչʾÈçºÎʹÓà Grails ʵÏÖ m:m ¹Øϵ£¬ÎÒÃÇÔÚ±¾ÏµÁÐÖпª·¢µÄ trip-planner Ó¦ÓóÌÐòÉϽøÐй¹½¨¡£ÔÚÌÖÂÛ trip-planner Ó¦ÓóÌÐò֮ǰ£¬ÎÒ»¹Ïë̸̸ͼÊéµÄÀý×Ó£¬ÒÔ°ïÖúÄúÀí½âÒ»¸öÒªµã¡£
µÚÈý¸öÀà
ÔÚÊý¾Ý¿âÖУ¬ÓÃÈý¸ö±í±íʾ m:m ¹Øϵ£ºÇ°Á½¸ö±íÄúÒѾ֪µÀÁË£¨Book ºÍ Author£©£¬µÚÈý¸öÊÇÒ»¸öÁ¬½Ó±í£¨BookAuthor£©¡£GORM Ïò BookAuthor Á¬½Ó±íÌí¼Ó book_id ºÍ author_id£
Ïà¹ØÎĵµ£º
½ñÌì¸ãÁËÎÒÈýËĸöСʱµÄÎÊÌ⣬ÖÕÓÚÕÒµ½½â¾ö·½°¸ÁË¡£¹þ¹þ¡£
ÔÚAjax¿ª·¢ÖУ¬»áÓöµ½ä¯ÀÀÆ÷»º´æÄÚÈݵÄÎÊÌ⣬±ÈÈ磬ij¸öÔªËØ×¢²áÁËÊó±êʼþ£¨onmouseover£©£¬Ê¼þ´¥·¢ºó»áͨ¹ýxmlhttprequestµ½·þÎñÆ÷»ñÈ¡ÄÚÈÝ£¬ÔÚ²»Ë¢ÐÂÒ³ÃæµÄÇé¿öÏ£¬ä¯ÀÀÆ÷»á»º´æµÚÒ»´ÎÇëÇóµÄÄÚÈÝ£¬·þÎñ¶Ë¸üкóä¯ÀÀÆ÷ÈÔÈ»ÏÔʾµÚÒ»´ÎµÄÄÚÈÝ¡£
ͨ³££¬ÕâÖÖÇëÇó¶ ......
±¾ÎĽ«Ê¹ÓÃAjaxToolkitÖеē PopupControlExtender £¬ DynamicPopulateExtender £¬ DragPanelExtender ”¿Ø¼þÀ´¹¹½¨Ò»¸öµ¯³ö¶Ô»°¿ò£¬¿ÉÒÔʵÏÖµ¯³ö¶Ô»°¿ò£¬¶Ô»°¿ò¿ÉÍ϶¯µÈ¹¦ÄÜ¡£±È½ÏÊʺÏ×öÿÈÕÒ»ÌùµÈЧ¹û
Ê×ÏȽâÊÍÏ ......
1 . jQuery°ïÖúÖ®AjaxÇëÇó£¨Ò»£©jQuery.ajax(options)
Òý×Ô:http://www.flywe.net/article/javascript/jQuery_ajax.html
jQuery.ajax(options)
ͨ¹ý HTTP ÇëÇó¼ÓÔØÔ¶³ÌÊý¾Ý¡£
......
½ñÌì°ïͬʽâ¾öÁËjsÒì²½µ÷ÓÃʱ³öÏÖÁËÖÐÎÄÂÒÂëµÄÎÊÌ⣬¾ßÌå½â¾ö°ì·¨ÈçÏ£º
1£©Ê×ÏÈÈ·ÈÏjsÊÇ·ñûÓжԺǫ́´«Êä¹ýÀ´µÄÖÐÎĽøÐнâÂë¡£
°´ÕÕÍøÂçÉÏдµÄ·½·¨Í¨¹ýjs¶ÔresponseµÄ¶ÁÈ¡³öÀ´Êý¾Ý½øÐжà´Î²âÊÔ£¬·¢ÏÖÈÔÈ»²»Äܽâ¾ö£¬Ï¸Ïë²»Ò»¶¨ÊÇ´Ë´¦ÎÊÌâ¡£¸Ä»»ÆäËû°ì·¨½â¾ö¡£
2£©Èç¹û½âÂë½â¾ö²»ÁË£¬ÔÙ¿´ÊÇ·ñÊÇÒòΪÍø ......
IDE£ºVisual Web Developer 2008 Express Edition
Êý¾Ý¿â£ºAccess 2007
µ½http://www.asp.net/ajax/downloads/ÏÂÔØAJAX Control Toolkit£¬½«AjaxControlToolkit.dll¿½±´µ½ÏîÄ¿µÄbinĿ¼Ï£¬ÔÚ¹¤¾ßÀ¸ÖÐÒýÈë¡£
WebServiceµÄ´úÂ룺£¨aaa.asmx£©
Public Function GetCompletionList(ByVal prefixText As String, ByVal coun ......