2파트-07

Similar documents
C H A P T E R 2

Ext JS À¥¾ÖÇø®ÄÉÀ̼ǰ³¹ß-³¹Àå.PDF

제이쿼리 (JQuery) 정의 자바스크립트함수를쉽게사용하기위해만든자바스크립트라이브러리. 웹페이지를즉석에서변경하는기능에특화된자바스크립트라이브러리. 사용법 $( 제이쿼리객체 ) 혹은 $( 엘리먼트 ) 참고 ) $() 이기호를제이쿼리래퍼라고한다. 즉, 제이쿼리를호출하는기호

3장

Microsoft PowerPoint - web-part03-ch19-node.js기본.pptx

Javascript.pages

Week13

Eclipse 와 Firefox 를이용한 Javascript 개발 발표자 : 문경대 11 년 10 월 26 일수요일

Analytics > Log & Crash Search > Unity ios SDK [Deprecated] Log & Crash Unity ios SDK. TOAST SDK. Log & Crash Unity SDK Log & Crash Search. Log & Cras

DocsPin_Korean.pages

ibmdw_rest_v1.0.ppt

Interstage5 SOAP서비스 설정 가이드

3ÆÄÆ®-14


신림프로그래머_클린코드.key

untitled

rmi_박준용_final.PDF

MasoJava4_Dongbin.PDF

Dialog Box 실행파일을 Web에 포함시키는 방법

UNIST_교원 홈페이지 관리자_Manual_V1.0

Overall Process

PowerPoint Template

Connection 8 22 UniSQLConnection / / 9 3 UniSQL OID SET

INDEX 들어가기 고민하기 HTML(TABLE/FORM) CSS JS

Macaron Cooker Manual 1.0.key

초보자를 위한 ASP.NET 2.0

Mobile Service > IAP > Android SDK [ ] IAP SDK TOAST SDK. IAP SDK. Android Studio IDE Android SDK Version (API Level 10). Name Reference V

thesis

untitled

초보자를 위한 C# 21일 완성

Domino Designer Portal Development tools Rational Application Developer WebSphere Portlet Factory Workplace Designer Workplace Forms Designer

04장

초보자를 위한 ASP.NET 21일 완성

- 이벤트의처리 <input type= button id= button1 value= 확인 /> <input type= button id= button2 value= 확인 /> 자바스크립트인경우 : document.getelementbyid( button1 ).oncl

슬라이드 1

제목을 입력하세요.

SK Telecom Platform NATE

JMF2_심빈구.PDF

HTML5가 웹 환경에 미치는 영향 고 있어 웹 플랫폼 환경과는 차이가 있다. HTML5는 기존 HTML 기반 웹 브라우저와의 호환성을 유지하면서도, 구조적인 마크업(mark-up) 및 편리한 웹 폼(web form) 기능을 제공하고, 리치웹 애플리케이 션(RIA)을

<4D F736F F F696E74202D E20C0CEC5CDB3DD20C0C0BFEB20B9D720BCADBAF1BDBA20B1E2BCFA E >

01_피부과Part-01

I T C o t e n s P r o v i d e r h t t p : / / w w w. h a n b i t b o o k. c o. k r

<C0CCBCBCBFB52DC1A4B4EBBFF82DBCAEBBE7B3EDB9AE2D D382E687770>

14-Servlet

DIY 챗봇 - LangCon

untitled

PHP & ASP

20주년용


10.ppt

Orcad Capture 9.x

Portal_9iAS.ppt [읽기 전용]

JMF3_심빈구.PDF

Building Mobile AR Web Applications in HTML5 - Google IO 2012

untitled

Social Network

Microsoft PowerPoint - web-part02-ch15-문서객체조작.pptx

PCServerMgmt7

example code are examined in this stage The low pressure pressurizer reactor trip module of the Plant Protection System was programmed as subject for

03장.스택.key

BEef 사용법.pages

PowerPoint 프레젠테이션

@OneToOne(cascade = = "addr_id") private Addr addr; public Emp(String ename, Addr addr) { this.ename = ename; this.a

untitled

untitled

Polly_with_Serverless_HOL_hyouk

Microsoft PowerPoint - 04-UDP Programming.ppt

13주-14주proc.PDF

API STORE 키발급및 API 사용가이드 Document Information 문서명 : API STORE 언어별 Client 사용가이드작성자 : 작성일 : 업무영역 : 버전 : 1 st Draft. 서브시스템 : 문서번호 : 단계 : Docum

PowerPoint 프레젠테이션

02 C h a p t e r Java

하둡을이용한파일분산시스템 보안관리체제구현

Microsoft PowerPoint - aj-lecture1-HTML-CSS-JS.ppt [호환 모드]

The Self-Managing Database : Automatic Health Monitoring and Alerting

슬라이드 1

Modern Javascript

jQuery.docx

컴퓨터과학과 교육목표 컴퓨터과학과의 컴퓨터과학 프로그램은 해당분야 에서 학문적 기술을 창의적으로 연구하고 산업적 기술을 주도적으로 개발하는 우수한 인력을 양성 함과 동시에 직업적 도덕적 책임의식을 갖는 IT인 육성을 교육목표로 한다. 1. 전공 기본 지식을 체계적으로

Java XPath API (한글)

PowerPoint 프레젠테이션

접근성과 웹 The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect. Tim Berners-Lee, the inventor

var answer = confirm(" 확인이나취소를누르세요."); // 확인창은사용자의의사를묻는데사용합니다. if(answer == true){ document.write(" 확인을눌렀습니다."); else { document.write(" 취소를눌렀습니다.");

<4D F736F F F696E74202D20B5A5C0CCC5CDBAA3C0CCBDBA5F3130C1D6C2F75F31C2F7BDC32E >

No Slide Title

Intro to Servlet, EJB, JSP, WS

산업입지내지6차

NoSQL

쉽게 풀어쓴 C 프로그래밍

(Humphery Kim) RAD Studio : h=p://tech.devgear.co.kr/ : h=p://blog.hjf.pe.kr/ Facebook : h=p://d.com/hjfactory :

00목차

01....b

2007백서-001-특집

(291)본문7

¾Ë·¹¸£±âÁöħ¼�1-ÃÖÁ¾

초보자를 위한 C++

1

자바GUI실전프로그래밍2_장대원.PDF

Multi Channel Analysis. Multi Channel Analytics :!! - (Ad network ) Report! -! -!. Valuepotion Multi Channel Analytics! (1) Install! (2) 3 (4 ~ 6 Page

ilist.add(new Integer(1))과 같이 사용하지 않고 ilist.add(1)과 같이 사용한 것은 자바 5.0에 추가된 기본 자료형과 해당 객체 자료 형과의 오토박싱/언박싱 기능을 사용한 것으로 오토박싱이란 자바 컴파일러가 객체를 요구하는 곳에 기본 자료형

untitled

Transcription:

CHAPTER 07 Ajax ( ) (Silverlight) Ajax RIA(Rich Internet Application) Firefox 4 Ajax MVC Ajax ActionResult Ajax jquery Ajax HTML (Partial View) 7 3 GetOrganized Ajax GetOrganized Ajax HTTP POST

154 CHAPTER 07 _ Suggest Ajax MVC jquery HTTP POST Todo Ajax jquery API Visual Studio Ajax Ajax Ajax jquery Ajax (Graceful degradation) Ajax 7 2 Ajax Ajax MVC IsAjaxRequest() Create() CreateWithAjax()

7.1 155 Ajax jquery jquery Visual Studio 2008 C# jquery http://jquery.com Visual Studio 2010 GetOrganized Ajax HTTP POST Todo Ajax 3 4 : Todo Ajax HTTP POST // GET: /Todo/Delete/Title={ } [AcceptVerbs(HttpVerb.Post)] public ActionResult Delete(string title) { 5 Todo.ThingsToBeDone. Remove( Todo.ThingsToBeDone.Find(todo => todo.title == title)); if (Request.IsAjaxRequest()) 10 return new EmptyResult(); return RedirectToAction( Index ); } http://code.msdn.microsoft.com/kb958502/release/projectreleases.aspx?releaseid=1736

156 CHAPTER 07 _ 2 Delete() HTTP POST HTTP POST /Views/ Todo/Index.aspx HTTP GET 9 Ajax Ajax EmptyResult jquery HTML /Views/Todo/Index.aspx Grid Grid HTML id class <A> NUnit LinkHelper ViewHelpers using System.Web.Mvc; using System.Web.Routing; namespace GetOrganized.ViewHelpers 5 { public static class LinkHelper { public static string Link(this HtmlHelper helper, string linktext, string url, object htmlattributes) 10 { var builder = new TagBuilder( a ); builder.mergeattributte( new RouteValueDictionary(htmlAttributes)); 15 builder.attributes.add( href, url); builder.setinnertext(linktext); return builder.tostring(); } 20 } }

7.1 157 HTML 6 2 9 6 1 HTML CSS id class Html.ActionLink( name, action, new { @class = SomeCssClass }) TagBuilder 14 RouteValueDictionary IDictionary <String Object> HTML jquery <head> <meta httpequiv= ContentType content= text/html; charset=iso88591 /> <link href=../../content/colorpicker.cssv 5 rel= Stylesheet type= text/css /> <link href=../../content/site.css rel= stylesheet type= text/css /> <link href=../../content/colorpicker.css rel= stylesheet type= text/css /> 10 <script type= text/javascript src=../../scripts/jquery1.4.1.js ></script> <script type= text/javascript src=../../scripts/colorpicker.js ></script> 15 <script type= text/javascript src=../../scripts/jquery.autocomplete.js ></script> <link href=../../content/jquery.autocomplete.css rel= stylesheet type= text/css /> 20 <script type= text/javascript src=../../scripts/jqueryui1.8rc3.min.js ></script> <script type= text/javascript src=../../scripts/jquery.livequery.js ></script> 25

158 CHAPTER 07 _ <asp:contentplaceholder ID= Head runat= server /> </head> jquery Site.Master 16 jquery AutoComplete jquery UI Live Query AutoComplete CSS CSS /Views/Todo/Index aspx HTTP POST <%@ Page Title= Language= C# MasterPageFile= ~/Views/Shared/Site.Master Inherits= System.Web.Mvc.ViewPage<IEnumerable<Todo>> %> <%@ Import Namespace= System.Drawing %> 5 <%@ Import Namespace= GetOrganized.Models %> <%@ Import Namespace= GetOrganized.ViewHelpers %> <%@ Import Namespace= MvcContrib.UI.Grid %> <asp:content ID= Content1 10 ContentPlaceHolderID= head runat= server > <title>index</title> <script type= text/javascript language= javascript > $(document).ready(function() { $(.deletetodolink ).click(function() { var element = $(this); var todotitle = element.attr( id ); $.post( Todo/Delete, 20 { title: todotitle }, function() { element.closest( tr ). fadeout( slow, function() { $(this).remove(); }); http://www.pengoworks.com/workshop/jquery/autocomplete.htm http://jqueryui.com/download http://plugins.jquery.com/project/livequery

7.1 159 25 } ); }); }); </script> 30 </asp:content> <asp:content ID= Content2 ContentPlaceHolderID= MainContent runat= server > <h2><%= ViewData[ UserName ] %> </h2> 35 <%= Html.Grid(Model).Columns(column => { column.for( x => Html.Link(, #, new { id = x.title, 40 @class = deletetodolink })).DoNotEncode(); column.for( x => Html.ActionLink(, Edit, new { x.title })). Named( ).DoNotEncode(); 45 column.for(x => x.title); }).Attributes(style => textalign: center; ).Empty(! ) %> 50 <p> <%= Html.ActionLink(, Create ) %> </p> </asp:content> jquery head ID ContentPlaceHolder jquery 6 GetOrganized ViewHelpers 39 Grid LinkHelper (Anonymous Object Initializer) class id jquery jquery

160 CHAPTER 07 _ 15 this jquery jquery HTML <A> id Todo Title Ajax 18 $ post() jquery HTTP POST URL HTTP POST Todo 22 element.closest( tr ) <TR> 24 remove() jquery fade() HTML F5 Todo Ajax Ajax GetOrganized jquery MVC

7.2 161 jquery 7 1 HTTP POST Site.Master jquery jquery JSON JQ Autocomplete jquery ThoughtController [Test] 2 public void Should_Find_Thoughts_By_Text_Match_Case_Insensitive() 3 { 4 var learncsharp = Thought.CurrentThoughts[0]; 5 var contentresult = ((ContentResult) 6 new ThoghtController().Search( ); 7 8 Assert.AreEqual(learnCsharp.Name, contentresult.content); 9 } C# 3 5 Thought jquery 6 Search ContentResult Search http://www.devbridge.com/projects/autocomplete/jquery/

162 CHAPTER 07 _ public ActionResult Search(string q) { var searchresults = Thought.CurrentThoughts.FindAll( thought => thought.name.tolower().contains(q.tolower())); 5 var autocompleteresults = String.Join( \n, searchresults.convertall(g => g.name).toarray()); 10 return Content(autoCompleteResults); } 1 q jquery q ( ) 4 ToLower() 167 TIP 8 Thought Name String Join \n Content(object result) Thought Id Thought Thought Name /Views/Thought/Detail/Id [Test] 2 public void Should_Find_Thought_By_Name_And_Redirect_To_Details_View() 3 { 4 var routevaluedictionary = new ThoughtController(). 5 FindDetails( C# 3.5 ). 6 AssertActionRedirect().RouteValues; 7 8 Assert.AreEqual( Details, routevaluedictionary[ action ]);

7.2 163 9 Assert.AreEqual(1, routevaluedictionary[ id ]); 10 } ThoughtController FindDetails() 4 Dictionary<String Object> RouteValueDictionary Id Thought FindDetails() // // GET: /Thought/FindDetails?nameOfThought={name} public ActionResult FindDetails(string nameofthought) 5 { var thought = Thought.CurrentThoughts. Find(x => x.name == nameofthought); return RedirectToAction( Details, 10 new { id = thought.id }); } Thought Id 10 Id Id LinkHelper MVC RouteValueDictionary jquery <asp:content ID= indexhead ContentPlaceHolderID= head runat= server > <title> </title> <script type= text/javascript language= javascript > 5 $(document).ready(function() { $( #searchthoughtstextbox ). autocomplete( Thought/Search, { minchars: 1 }); $( #searchbutton ).click(function() { window.location = Thought/FindDetails?nameOfThought= + 10 escape($( #searchthoughtstextbox )[0].value); }); }); </script>

164 CHAPTER 07 _ </asp:content> 15 <asp:content ID= indexcontent ContentPlaceHolderID= MainContent runat= server > <! > 20 <h2> </h2> <input id= searchthoughtstextbox name= title type= text /> <input id= searchbutton type= submit value= /> </asp:content> 21 Thought 7 HTTP GET URL {minchars: 1} 9 jquery window location 10 getelementbyid() jquery jquery $( class )[0] escape() URL 7 1

7.2 165 jquery UI ( 4 3 jquery ) jquery Ajax ( 7 2 ) MVC MVC http://www.uploadify.com/ http://www.codenothing.com/archives/jquery/inlinetextedit/ http://blog.threedubmedia.com/2008/08/eventspecialdrag.html http://bassistance.de/jqueryplugins/jquerypluginvalidation/

166 CHAPTER 07 _ Ajax (Partial View) ASP NET (User Control) Views/Shared LogOnUserControl ascx Site Master GetOrganized /Views/Todo/Create aspx Todo /Views/Todo/Create aspx (DRY ) Create aspx Create aspx ( 7 3 ) Create aspx CreateElements aspx

7.3 167 TIP http://lucene.apache.org/java/docs/index.html http:// ayende.com/blog/archive/2007/03/18/googlizeyourentitiesnhibernatelucene.netintegration.aspx <%@ Control Language= C# Inherits= System.Web.Mvc.ViewUserControl %> <% using (Html.BeginForm()) { %> <fieldset> <legend>fields</legend> 5 <div class= editorlabel > <%= Html.LablFor(model => model.title) %> </div> <div class= editorfield > <%= Html.TextBoxFor(model => model.title) %> 10 <%= Html.ValidationMessageFor(model => model.title) %> </div> <p> <input type= submit value= /> </p> 15 </fieldset> <% } %>

168 CHAPTER 07 _ HTML 1 System.Web.Mvc.ViewUserControl id CreateTodo jquery Ajax Create aspx <asp:content ID= Content2 ContentPlaceHolderID= MainContent runat= server > <h2> </h2> 5 <%= Html.ValidationSummary() %> <% Html.RenderPartial( CreateElements ); %> <div> 10 <%= Html.ActionLink(, Index ) %> </div> </asp:content>

7.3 169 7 RenderPartial(string partialname) /Views/Todo/CreateElements aspx MVC WebFormViewEngine /Views/Todo /Views/Shared MVC (! ) http://code.google.com/p/nhaml/ http://code.google.com/p/stringtemplateviewenginemvc/ if/else ViewData F5 Create aspx Ajax

170 CHAPTER 07 _ CreateElement.aspx /Views/Todo/Index aspx Todo /Views/Todo/Index aspx <div> <asp:content ID= Content1 ContentPlaceHolderID= Head runat= server > <script type= text/javascript language= javascript > $(document).ready(function() { // $( #Create_Link ).click(function() { $( #Create_Div ).slidetoggle( slow ); }); $( #Create_Link )[0].href = # ; }); </script> </asp:content> <asp:content ID= Content2 ContentPlaceHolderID= MainContent runat= server > <! Grid > <p> <%= Html.ActionLink(, Create, null, new { id= Create_Link }) %> </p> <div id= Create_Div style= display:none > <% Html.RenderPartial( CreateElements ); %> </div> </asp:content> 22 display none 19 <div> <div> id jquery 8 slidetoggle(var speed) <div>

7.3 171 10 Create aspx 7 4 /Views/Todo/Create aspx Todo jquery post() TodoController JSON // POST: /Todo/Create [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(Todo todo) { 5 todo.validate(modelstate); if (ModelState.IsValid) {

172 CHAPTER 07 _ CreateTodo(todo); 10 if (Request.IsAjaxRequest()) return Json(todo); return RedirectToAction( Index ); } else 15 { return View(); } } 10 IsAjaxRequest() Ajax 7 1 Ajax Ajax Ajax HTTP X Requested With: XMLHttpRequest IsAjaxRequest() true Ajax JSON Index aspx jquery Todo <asp:content ID= Content1 ContentPlaceHolderID= head runat= server > <script type= text/javascript language= javascript > $(document).ready(function() { 5 $( #CreateTodo ).submit(function() { $.post( $(this).attr( action ), $( #CreateTodo ).serialize(), 10 function(data, textstatus) { var html = <tr><td><a id=\ + data.title + \ + class=\ deletetodolink\ href=\ #\ > + </a></td> + 15 <td><a href=\ /Todo/Edit?Title= + data.title + \ > </a></td> + <td> + data.title + </td></tr> ; $(html).appendto($( #main table )).

7.3 173 10 effect( highlight, {}, 3000); }, // json ); 25 return false; }); } Todo HTML (DOM: Document Object Model) 5 submit jquery post() HTML action URL Ajax serialize() <input> 8 post() post() Todo 11 JSON Todo 20 jquery JSON 23 post() jquery jquery (Live Query) <script type= text/javascript language= javascript > $(document).ready(function() { $(.deletetodolink ).livequery( click, function() { var element = $(this);

174 CHAPTER 07 _ 5 var todotitle = element.attr( id ): $.post( Todo/Delete, { title : todotitle }, 10 function() { element.closest( tr ). fadeout( slow, function() { $(this).remove(); }); } 15 ); }); }); </script> </asp:content> 3 click(function()) livequery( click function()) DOM append() addclass() DOM jquery DOM jquery Ajax 2 0! jquery $.post() Ajax ASP NET ORM SQL NHibernate ORM