MVC animated Internet Course Dr Solange Karsenty View

  • Slides: 4
Download presentation
MVC animated Internet Course Dr Solange Karsenty

MVC animated Internet Course Dr Solange Karsenty

View - ל Controller- עם העברת נתונים מ MVC שמחזיר דף – מבנה FORM

View - ל Controller- עם העברת נתונים מ MVC שמחזיר דף – מבנה FORM טעינה של דף הכולל לקוח (WAN) רשת http תקשורת שרת thankyou. ejs GET /pay Name: Cc: This is your Exp date: http: //xy. com/pay confirmtation: 123 [PAY] Thank you! <form action="/paynow" method="post" …> POST /paynow /views xy. com http serv er payform. ejs /routes route. get(‘/pay', function(req, res) { // … Views /models res. render(‘payform’); } <p>This is your confirmation: 123 Thank you!</p> Browser now points to: http: //xy. com/paynow <p>This is your confirmation: <%= confirmnum %>. Thank you!</p> Models route. post(‘/paynow', function(req, res) { // process payment… {confirmnum: “ 123”} res. render(‘thankyou’, {confirmnum: “ 123”}); } Controllers

View - ל Controller- עם העברת נתונים מ MVC שמחזיר דף – מבנה FORM

View - ל Controller- עם העברת נתונים מ MVC שמחזיר דף – מבנה FORM טעינה של דף הכולל לקוח (WAN) רשת http תקשורת שרת thankyou. ejs GET /pay Name: Cc: This is your Exp date: http: //xy. com/pay confirmtation: 123 [PAY] Thank you! <form action="/paynow" method="post" …> POST /paynow <p>This is your confirmation: 123 Thank you!</p> Browser now points to: http: //xy. com/paynow <p>This is your confirmation: <%= confirmnum %>. Thank you!</p> /views xy. com http serv er payform. ejs DB Views Controllers route. get(‘/pay', function(req, res) { // … res. render(‘payform’); /routes /models } User route. post(‘/paynow', function(req, res) { User u = User. find. By. Id(……) Payment p = Payment. create({ amount: 100, date: … } ); {confirmnum: “ 123”} res. render(‘thankyou’, {confirmnum: p. confirmation}); } Product Payment Models

Controller are the central component. Controller access models and views, but not the opposite

Controller are the central component. Controller access models and views, but not the opposite Controllers return JSON data or Controller return Views, but not the opposite שימו לב לכללי שמירת הפרדת תפקידים Views receive data, views don’t handle heavy logics Controller handle logics Only models access the database