0

I had gone through a lot of docs and blogs but still not clear of how flow happens in ExtJs MVC (with JSON data). Below are the doubts which I have.

  1. What is the use of Extjs Model. I know that it can be used for validation and association but is there any specific use of it and when to use it.

  2. What is the difference between an Extjs Model and Store.

  3. I know that the events are basically written in the controller of Extjs. So, if I click a save button in the UI, how should I explain the process a) Should I say that, on save the data is fetched from the store by the controller event and transferred to the spring controller or the data is fetched from the model

  4. What would be the right place to use the proxy to get the data, is it model or store?

Please help me understand the concepts cearly...

Peter Ivan
  • 1,467
  • 2
  • 14
  • 27
CARTIC
  • 573
  • 3
  • 14
  • 26

1 Answers1

0

ONE - You don't need to use ExtJS Models, you could just turn your JSON directly into Javascript objects, but Model:

  • provides pseudo strong typing
  • provide arbitrarily deep association getters and setters
  • allow for easier form data-binding - form.loadRecord(someModel)
  • allow for structured validation
  • easy to change from JSON to XML format using different readers

TWO - A store is a collection of models. It has some useful methods like sort(), filter(), group(), count()

THREE -_ This question could be clearer. Spring runs on the server and ExtJS runs on the client. They are two different processes. You could run an ExtJS client entirely distinct from Spring.

  • User clicks button
  • View raises click event
  • Controller handles click event
  • Controller maybe asks store to load itself (which makes an HTTP request to get some data from where it doesn't matter)
  • View (Grid) was listening for store load event and now updates self

(This is essentially the Supervising Controller pattern, see Fowler)

FOUR - Doesn't matter if the proxy is in the model or store. Store will inherit its model's proxy if only model has one. Easier to deal with singular models if the proxy is in the model.

Neil McGuigan
  • 46,580
  • 12
  • 123
  • 152