Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have an Ember template .hbs file with its controller and route. I do not have a component.js file for it. What is an Ember not-quite-component called?
When you type a URL into your browser, the Ember Router has a route, or routes, that handle that particular URL.
The Route can render a template, assign a model, handle actions, redirect to a new route, etc.
A route's associated Controller can be customized if needed, to handle actions or custom properties, for instance.
If the route renders a Template, a component might then be called in the template, or it might not.
A Component typically encapsulates HTML mark-up and functionality that is intended for reusability in some fashion, or to isolate a subset of concerns. If no JavaScript is needed, a component template can be used individually. If JavaScript is required for additional functionality, a component subclass for the component template would also be necessary.
You could say a controller is "not quite a component", given that it behaves in much the same way as a component. However, the template a controller is associated with, is rendered by its route.
You just named it. "Controller", "Route" and "Template". The template belongs to the controller and the controller belongs to the route. A default controller is magically provided for you if you do not define one, and an empty template is also provided by default. If you are speaking to someone and need to convey what you have, the route can somewhat be assumed since it is the only thing absolutely required to reach a page, thus you can simply say "my controller".
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
Firstly, the scenario in my question:
I want to deliver a form in bitesize stages, with the valid completion of one stage leading to the next until all stages are complete.
On completion, I'd like to use data once, and then forget it completely so I'm not holding on to any user data at all.
My options as I see it are:
Multiple views each with a unique form all bound to a single model. The final submit button in the chain triggers data in the model to be accessed, used and then that particular row removed.
Multiple views each with unbound forms, each adding data to a cookie, which is then read on the final submit, data used and the cookie deleted (either using sessions or plain old js hard coded into each template).
A single view and template containing a single unbound form, which progressively un-hides divs containing each stage until all stages are completed and final 'submit' posts data from the form, allows a view to process it and forgets it.
I can actualise all three of the above, but which is the most 'Djangonic' method, or is there a better method still?
There is a library made from the Django guys for this case: https://django-formtools.readthedocs.io/en/latest/wizard.html
It's not dynamic though, so when you click "proceed", it will render a new page. But you can probably write a javascript module, that can handle this. But I wouldn't go that far, it's a lot of work for little benefit. Just just django-form-tools and use the wizard you want and do whatever you need in the done stage of your view.
I know this question might seem a little duplicate but the other version of this question is old and some of the content (such as Views) aren't even a part of ember anymore.
I'm about 4 weeks into my internship as a front-end developer working with EmberJS. I still don't understand when it's better to use the route over the controller or vice-versa. It seems to me that every action in the route can also be used in the controller.
The one recent thing I heard was that ember routes should be stateless where as controllers should be stateful.
What is the current state of controllers and routes. When should one be used over the other?
Consider the following example to understand the state of a controller (or route, or anything), in simple terms and in current context -- lets say you have a page (like a form) with three tabs; each tab can be considered as a state - it would call different components based on the state (or the tab you are in). Now if you would happen to go back for some reason, and hit the form link again, you would see that the state would remain the same. (if you were on tab 2 when you hit back, on returning to the form, you would still be on tab 2).
So to maintain these states, controllers are the way to go, since they are singletons. Route would have lost that information, and started fresh. So basically your variables/objects in a controller would define the 'state'.
Route-actions can be as easily used as controller actions- see https://github.com/DockYard/ember-route-action-helper. So if your template for this route is just using model as the object directly, and you don't need to maintain the 'state', you can pretty much do without your controller.
But if your template was using variables which needed manipulation, you would need controller.
Hope this helps!
Using ember: 1.7.0
I'm trying to used different loading templates depending on the route that is being transitioned to in my app. None of my routes are nested (i.e. contained within a resource). I've only been able to get ember to serve up the application loading template. Is there a way to override this behavior in the case of non-nested routes?
Here's a jsbin illustration the problem:
Two loading templates are defined loading and top-loading.
When loaded up the app transitions to the top route.
I was hoping this would trigger the top-loading template, but instead it triggers the loading template.
http://emberjs.jsbin.com/pamego/1/
Thanks in advance for any assistance!
I'm going to do that thing where I question a premise of your question:
If your routes aren't nested then there should be no harm in treating them as resources. Routes only have special behavior when they are nested (they don't reset their namespace).
Conceptually, changing this route to a resource works. The "loading" state is really an enhancement or a special form of "top". When something has multiple states like this, modeling it as a resource makes sense. With all that preamble, I propose this:
http://jsbin.com/javihuceqo/1/edit?html,js,output
The problem is that your route is only nested one level deep, so the application-level loading substate is active. If you had a Route that was 2 levels down, "FooBar", for example, then trying to load the FooBarRoute model would cause the foo/loading template to be displayed.
Please see this jsbin for an example.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Qt/Qml uses model/view architecture Model/View Programming Model/View Tutorial but their examples are too simple. I want to know how it should look with more complex problem. Assume that we have Application. According to Qt's model/view architecture the best solution is to create ApplicationModel, ApplicationView and ApplicationDelegate. Now lets our Application to have a Console and other components. Console should be separated to ConsoleModel, ConsoleView and ConsoleDelegate. But Console has its own Input and Output, that should be separated to ConsoleOutputModel, ConsoleOutputView, ConsoleOutputDelegate and ConsoleInputModel, ConsoleInputView, ConsoleInputDelegate.
But how does it all should be combine? Should ApplicationModel contains ConsoleModel that contains ConsoleOutputModel and ConsoleInputModel? It makes sense, but what about views and delegates? Similarly or ApplicationDelegate should control ConsoleView and ConsoleDelegate? How then ConsoleOutputModel should be accesed by ConsoleOutputView?
I would be very grateful for every hint or example solution.
What you imply is mostly incorrect. There's no reason to nest models, unless you wish to logically combine their data - and if so, you'd need to write a custom proxy model to do so. Existing proxy models provided by Qt have only one source model. This is just what's there, doing a multi-source proxy is certainly possible.
In Qt's model-view model, a delegate has a specific meaning: it is the visual "skin" used to interact with the item. It specifically derives from the the QAbstractItemDelegate class. The delegate concept applies to the viewed items from the model, not to the view as a whole. You may need many delegates, not just one, or no delegates at all. It's not the same as the delegate concept from model-view-controller.
Another issue I see is with demanding that the entire application is an ApplicationView. Qt doesn't provide views that would construct a widget-based user interface of the entire application using the QAbstractItemModel as a data source. The closest you get is QUiLoader which can load an .ui XML file and instantiate the UI objects - but that does not use the model-view framework, and is a one-time action: any changes to the underlying XML model are not propagated automatically.
The way models and views are typically used in Qt is to couple a model to one or more view widgets. Those widgets then show some subset of the model (perhaps the full model) in a particular way. You can even couple a model to any widget's property using the QModelWidgetMapper.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I was wondering what kind of MVC pattern the illustration below is. We are developing a web application according to this pattern using ColdFusion and it goes pretty well so far. But is it even some kind of MVC at all?
A frontend page usually consists of:
- including the corresponding gateways (each model component has its own gateway with dedicated functionality)
- using the provided GATEWAY struct (contains components, arrays, structs etc. representing the desired data) to render output
- simple flow control (if/else/loops) to iterate through the provided data or distinguish view states
- if required: build forms (POST to same page) and name their field names according to GATEWAY specifications
The GATEWAY file (always separated from frontend page) validates the request (usually POST data) and takes care of the data retrieval (i.e. selects/inserts/updates on database). Usually the GATEWAY requests data regardless of actions (evaluation of runetime data like SESSION). All operations are fail-safe, so either there is data in the resulting struct or the data is empty. Either way, two arrays (success, errors) in the struct provide a log of all performed actions during the processing to react accordingly on the frontend page. Most data is provided as components (objects), but all in all it is not a fully object-orientied approach. The only thing they have in common is: they all describe input parameters (GET, POST, Session, Cookie) and outgoing parameters, like a (RESTful) web service.
I came up with a lot of ideas about the used pattern, but I wasn't able to match it in all regards yet.
To my mind the most important thing MVC provides is the separation between your view and your model. By doing this you can completely replace the view or the model without having to make changes to the other. In fact the main purpose of the controller is to act as the man in the middle between the two. Need to switch database servers, you shouldn't have to change out your view, or even your controller really. Need to create a new view, or replace the view you have, again you shouldn't have to mess with your model or controller really.
Ask yourself those questions about this proposed framework your going to create and the answers should come easy.