PDA

View Full Version : Big Application - Defining Views



SvenDiego
21 Oct 2009, 10:28 PM
Hi,

I'm new to ExtJS and want to port our app to Ext. At the moment we have a server app with more than 100.000 lines of code. the server is responsible for generating the html markup.

i've read saki's tutorial about "Big Applications" and have a few questions:

1. do i have to design every view upfront in my "app.js", if i want to use ext components and layout? that is my understanding right now. if i use this approach i get a clean seperation of business logic and GUI. so every data i load will be of type JSON?!

2. only where simple html is enough i don't have to define the view. i just need to know the div to update its content?!


is this correct?

at the moment i use jquery for scripting. every time the ajaxRequest completes i script some gui things. but the server response is "always" html.

mitchellsimoens
22 Oct 2009, 2:26 PM
1. do i have to design every view upfront in my "app.js", if i want to use ext components and layout? that is my understanding right now. if i use this approach i get a clean seperation of business logic and GUI. so every data i load will be of type JSON?!

Everything doesn't HAVE to be JSON. You can use a simple AJAX request to return anything. JSON is just easy to use if say you wanted to display a component like a gridPanel.


2. only where simple html is enough i don't have to define the view. i just need to know the div to update its content?!

As I just said, when you call an AJAX request and when you get your response you can update anything with it. It doesn't have to be an ExtJS component.

example..


Ext.Ajax.request({
waitMsg: "Please wait...",
url: "functions.php",
params: {
task: "GET-SOMETHING"
},
success: function(response){
//do something with response.responseText
},
failure: function(response){
Ext.MessageBox.alert('error','Something went wrong');
}
});

SvenDiego
23 Oct 2009, 6:39 AM
Everything doesn't HAVE to be JSON. You can use a simple AJAX request to return anything. JSON is just easy to use if say you wanted to display a component like a gridPanel.

yes, i understand that not everything has to be json. that just should have been an example by me.



As I just said, when you call an AJAX request and when you get your response you can update anything with it. It doesn't have to be an ExtJS component.

the question is, do i have to design the view upfront? so if i want to show the response in example a new Ext.Panel, i will "lazy initialize" my view and put the response in it??!

or is there another way to create new views from the server side? something like a <script> element in the response to "inject" a new view?

my concern is, that the app will get pretty big, if i define every view in my app.js and what about memory consumption and performance?
the app has to run on ie6 and you all know how good that browser performs... :(

mschwartz
23 Oct 2009, 6:50 AM
I went through a similar exercise with a very large (250K+ lines) PHP application. The server generated all of the HTML markup and forms and so on, as you describe.

To get started, I implemented the basic layout of the application in ExtJS. The viewport, the layout, the menus, and so on. The initial framework didn't involve working with the PHP application yet.

Once the basic layout was done, I found the managed iframe extension and used it to have the server generate its forms/dialogs/etc. within the new layout.

Then I gradually reimplemented each bit of it with the Ext user interface components, implementing new PHP code (URLs) as JSON services for the ExtJS front-end that made the same PHP framework calls that those forms' actions called.

It's gotten to the point where I'm removing a lot of dead/useless server code now that is being handled by the ExtJS front-end.

SvenDiego
26 Oct 2009, 7:56 AM
thank you mschwartz,

that was exactly the information i was looking for. i just needed to know that i'm going in the right direction.
this library is so big, that it is not easy for beginners to get going. the tutorials didn't help me and it was not easy to find the a term to search for in the forum.

thanks again!