Ajax design patterns

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Ajax design patterns

Post by Christopher »

VladSun wrote:Back to the topic ;)
VladSun wrote:...So, we have MVP here ;)
Any comments on this one?
My impression is that MVP is just MVC with fat Controllers. I guess if you have your Controllers doing a lot of work on context switching -- maybe. But is Ajax really that difficult/different? I think the discussion is really about the different schemes to respond with whole HTML pages or partials (of any sort).
(#10850)
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Ajax design patterns

Post by josh »

Yeah I agree and with either option you could/could not duplicate the markup, so I don't really think thats a deciding factor either
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: Ajax design patterns

Post by kaisellgren »

@VladSun, I'm developing similar software. Here's a screenie: http://ioj.com/v/c4qgx

My views are not server-side, but client-side. This is my hobby project, a web version of Windows interface. I have made Window, Textbox, Textarea, Radiobox, Checkbox, Tabs, Panels, Labels and Scrollbars so far. Next I'm going to build up editable select boxes. The HTML 5 & CSS 3 is all built up with JS. All those shadows, corners, gradients, glows are made with CSS. There's only one picture texture.png which gives a texture to graphics and icons/buttons of course.

The way it works in principle is that the application loads the main component, which in turn loads each required subcomponents, and this all is done based on the user's permissions via AJAX. For example, if he can edit blog posts, then load blog window module that and all required components for it. PHP does not handle views at all, it returns JSON only. In my system, it goes like User <-> View <-> Controller <-> Model. Controller handles logic, validation, etc. Model handles the retrieval or saving of data.

The app fails miserably if you don't have JS. However, that's my requirement, I'm not working on a web site, I'm working on a web application. It still works on IE and others. It degrades gracefully. This also applies to HTML and CSS. If you are using IE, you won't see nice gradients there. I've built a browser capability class which finds out what the browser is capable of displaying, and based on that I display things differently. So, I'm not doing user agent targeting of any sort.

The way things work in my app right now is that when you open a control panel and you add a new user account, for instance, it will send an AJAX request, and based on its success, it will directly write to the View. I have no duplicate view code. And if you remove a user account, and the removal failed, it would make the user account field to go red with an error sign and a message containing useful information.

Third-parties are allowed to create modules (which runs as applications = windows). Here's an example code that will create a window:

Code: Select all

my-project-namespace-here.createApplication(
{
folder: 'test',
title: 'Control Center',
 
iconTaskbar: 'home.png',
iconWindow: 'home_small.png',
 
width: 256,
height: 320,
minWidth: 128,
minHeight: 32,
maxWidth: 320,
maxHeight: 320,
 
singleton: false,
resizable: true,
 
showInTaskbar: true,
showCloseButton: true,
showMaximizeRestoreButton: true,
showMinimizeButton: true,
showIcon: true,
 
content: 
[
 {type: 'checkbox', value: 'Sample value', x: 64, y: 48, width: 256},
 {type: 'checkbox', value: 'Another', x: 64, y: 96, width: 256},
 {type: 'checkbox', value: 'Yet another one', x: 64, y: 240, width: 256}
]
 
});
You can setup properties like Parent to make its parent not-selectable while the window is open, and lots of other cool stuff. All windows are kill-able through Task Manager and my friend already made the first virus for my web-Windows hehe. :)

I also like ExtJS, but I wanted to do something on myself (to educate myself, to get experience and show off skills, etc). Anyway, my point was that a web application does not always need to be SEO friendly nor does it have to be non-JS compatible.
Post Reply