Escolar Documentos
Profissional Documentos
Cultura Documentos
Lead Developer,
AJAX Frameworks
a bit of history...
Database
a bit of history...
Database
a bit of history...
Database
JavaScript
Client JavaScript
(webservice client and a response handler)
Even though this is a more sophisticated page, the three-file minimum stays the same: HTML File, Data WebService and Client JavaScript
issues?
Structure of three files completely dependent on structure of the data feed (e.g. the fields of an Issue object); HTML File, Data WebService and Client JavaScript all need to understand what an Issue is Confusion as to where Business Logic or Security would go
client-side ajax
Code maintenance:
3 languages, 4 tiers
server-side ajax
PHP generates
the key client JavaScript
(via traditional MVC approach)
Minimizes security
Thursday, October 22, 2009
the strategy
Implement a true MVC
approach
componentize your
HTML Controls on the server methodologies
<h3>Please select a country</h3> <select id="country"> <option>China</option> <option>Japan</option> <option>Taiwan</option> <option>UK</option> <option>USA</option> .... </select> <p>Lorem ipsum dolorem est...</p>
the strategy
Implement a true MVC
approach
componentize your
HTML Controls on the server methodologies
<h3>Please select a country</h3> <?php $countrySelect->render(); ?> <p>Lorem ipsum dolorem est...</p>
the strategy
Implement a true MVC
approach
componentize your
HTML Controls on the server methodologies
$countrySelect->addChangeAction("countryChanged"); function countryChanged() { $stateArray = States::LoadArrayForCountry ($countrySelect->selectedValue); $stateSelect->removeAllOptions(); foreach ($stateArray as $state) { $stateSelect->addOption($state); } }
event-driven in detail
Use Form State Every HTML Control Form State is
<?php /* Listing for address.php */ $form = new Form(); if ($form->isNew()) { $countrySelect = new Select($form); $countrySelect-> addChangeAction("countryChanged"); ... $stateSelect = new Select($form); $stateSelect->enabled = false; ... } function countryChanged() {...} include("address.tpl.php"); ?>
event-driven in detail
Use Form State Every HTML Control Form State is
<html><body> <?php $form->render(); ?> Country:<br/> <?php $country->render(); ?> State:<br/> <?php $state->render(); ?> </body></html>
event-driven in detail
Use Form State Every HTML Control Form State is
<html><body> <form action="address.php"> <input type="hidden" id="formState" value="abcd1234..."/> Country:<br/> <select id="country" onchange="form.submit();"> ... </select> State:<br/> <select id="state">...</select> </body></html>
event-driven in detail
<html><body>
<html><body> <form action="address.php"> <input type="hidden" id="formState" value="abcd1234..."/> Country:<br/> <select id="country" onchange="form.submit();"> ... </select> State:<br/> <select id="state">...</select> </body></html>
Form State is
event-driven in detail
Use Form State Every HTML Control Form State is
<?php /* Listing for address.php */ $form = new Form(); if ($form->isNew()) { $countrySelect = new Select($form); $countrySelect-> addChangeAction("countryChanged"); ... $stateSelect = new Select($form); $stateSelect->enabled = false; ... } function countryChanged() {...} include("address.tpl.php"); ?>
the strategy
Implement a true MVC
approach
componentize your
HTML Controls methodologies
which controls have changed and only return the updated HTML for those controls simple DOM replacements
coding demo
qcodo
Developed in 2001
Open Sourced in 2005 MIT License Comprehensive MVC Server-Side AJAX
closing thoughts...