Difference between revisions of "Documentation/DevGuide/Forms/The Model-View Paradigm"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
 
(2 intermediate revisions by 2 users not shown)
Line 7: Line 7:
 
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Forms/{{SUBPAGENAME}}}}  
 
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Forms/{{SUBPAGENAME}}}}  
 
  {{DISPLAYTITLE:The Model-View Paradigm}}
 
  {{DISPLAYTITLE:The Model-View Paradigm}}
A basic concept to understand about forms and controls in {{PRODUCTNAME}} is the model-view paradigm. For a given element in your document,for example, a text field in your HTML form, it says that you have ''exactly one'' model and an arbitrary number of views.
+
A basic concept to understand about forms and controls in {{AOo}} is the model-view paradigm. For a given element in your document, for example, a text field in your HTML form, it says that you have ''exactly one'' model and an arbitrary number of views.
  
 
The model is what is part of your document in that it describes how this element looks, and how it behaves. The model even exists when you do not have an open instance of your document. If it is stored in a file, the file contains a description of the model of your element.
 
The model is what is part of your document in that it describes how this element looks, and how it behaves. The model even exists when you do not have an open instance of your document. If it is stored in a file, the file contains a description of the model of your element.
Line 15: Line 15:
 
The view is a visual representation of your model. It is the component which looks and behaves according to the requirements of the model. You can have multiple views for one model, and they would all look alike as the model describes it. The view is visible to the user. It is for visualizing the model and handles interactions with the user. The model, however, is merely a "dumb" container of data.
 
The view is a visual representation of your model. It is the component which looks and behaves according to the requirements of the model. You can have multiple views for one model, and they would all look alike as the model describes it. The view is visible to the user. It is for visualizing the model and handles interactions with the user. The model, however, is merely a "dumb" container of data.
  
A good example to illustrate this is available in {{PRODUCTNAME}}. Open an arbitrary document and choose the menu item '''Window > New Window'''. A second window is opened showing the same document displayed in the first window. This does not mean that the document was opened twice, it means you opened a second view of the same document, which is a difference. In particular, if you type some text in one of the windows, this change is visible in ''both'' windows. That is what the model-view paradigm is about: Keep your document data once in the model, and when you need to visualize the data to the user, or need interaction from the user that modifies the document, create views to the model as needed.
+
A good example to illustrate this is available in {{AOo}}. Open an arbitrary document and choose the menu item {{menu|Window|New Window}}. A second window is opened showing the same document displayed in the first window. This does not mean that the document was opened twice, it means you opened a second view of the same document, which is a difference. In particular, if you type some text in one of the windows, this change is visible in ''both'' windows. That is what the model-view paradigm is about: Keep your document data once in the model, and when you need to visualize the data to the user, or need interaction from the user that modifies the document, create views to the model as needed.
  
 
Between model and view a 1:n relationship exists:
 
Between model and view a 1:n relationship exists:
Line 22: Line 22:
  
  
{{Documentation/Note|Note that the relation is directed. Usually, a view knows its model, but the model itself does not know about the views which visualize it.}}
+
{{Note|Note that the relation is directed. Usually, a view knows its model, but the model itself does not know about the views which visualize it.}}
  
 
{{PDL1}}
 
{{PDL1}}
  
 
[[Category:Documentation/Developer's Guide/Forms]]
 
[[Category:Documentation/Developer's Guide/Forms]]

Latest revision as of 11:27, 16 January 2024



A basic concept to understand about forms and controls in Apache OpenOffice is the model-view paradigm. For a given element in your document, for example, a text field in your HTML form, it says that you have exactly one model and an arbitrary number of views.

The model is what is part of your document in that it describes how this element looks, and how it behaves. The model even exists when you do not have an open instance of your document. If it is stored in a file, the file contains a description of the model of your element.

Documentation note.png In UNO, the simplest conceivable model is a component implementing com.sun.star.beans.XPropertySet only. Every aspect of the view could then be described by a single property. In fact, as you will see later, models for form controls are basically property sets.

The view is a visual representation of your model. It is the component which looks and behaves according to the requirements of the model. You can have multiple views for one model, and they would all look alike as the model describes it. The view is visible to the user. It is for visualizing the model and handles interactions with the user. The model, however, is merely a "dumb" container of data.

A good example to illustrate this is available in Apache OpenOffice. Open an arbitrary document and choose the menu item Window → New Window. A second window is opened showing the same document displayed in the first window. This does not mean that the document was opened twice, it means you opened a second view of the same document, which is a difference. In particular, if you type some text in one of the windows, this change is visible in both windows. That is what the model-view paradigm is about: Keep your document data once in the model, and when you need to visualize the data to the user, or need interaction from the user that modifies the document, create views to the model as needed.

Between model and view a 1:n relationship exists:

The Model View Paradigm


Documentation note.png Note that the relation is directed. Usually, a view knows its model, but the model itself does not know about the views which visualize it.
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages