I am beginner and coding an app where there are menus, accessible through an Activity "Dashboard". These menus are related : for example there are database that we complete in menu A and which we use in menus B and C. I have some questions, because I haven't read things useful for me... :
Do I have to use Activity or Fragment for my menus ? Knowing that when we enter a menu, there will be different sub-menus proposed, and that menus are related
About ViewModel : how will they be useful in my case (for example, will my databases be lost if I rotate the screen without ViewModel) ? If my menus are Activities, do I have to associate them ViewModel, or are those only for Fragments ? I'm a bit lost ... Thank you !
Read your full post, tried to understand and as per as I understood, trying to answer as follows.
From your use case, you should use Activity to contain the main dashboard and use fragments for other menus.
About viewmodel, when you are not using viewmodel with your data, if before rotation you didn't save those data somewhere (i.e database), then those data will be lost. But, if you saved your data in database then you can retrieve those data after rotation and re-use in your views. But, preferred way is to use viewmodel here, as your viewmodel can be the primary store for your data. Viewmodels are not only meant for fragments it can be used for activities too.
Related
I had tried the tutorial https://learn.microsoft.com/en-us/aspnet/core/data/ef-rp/intro?view=aspnetcore-3.1&tabs=visual-studio
And I am able to display the data with Razor pages with page model.
However, when I was trying to find ways to display a student name at the top using the common layout page, Shared_layout.cshtml, I got lost and would hope to seek your advice on how I could query for the data from the Student Entity and display just one name in the common layout page.
I felt lost because there is no page model for the common layout page.
Note: I am new to application development, so hope you could provide some guidance to enlighten me. Any good learning reference would be great as well :)
You can use ViewBag to display student name at the top.
Add ViewBag in all your action methods where you are returning view as return type from controller files.
ViewBag.StudentName = "Yiwen";
Use it in your common layout file.
#ViewBag.StudentName
You can see microsoft link on how to use ViewBag.
A little bit of background first. I learned in the past how to use "pure" php, and have more recently started using Symfony. I have been following several guides (Cookbook, Lynda & Openclassrooms) for many of my inquiries, but I haven't been able to find an answer for my current question.
I have two entities, let's name them User and Player. The User entity contains a Player property which can be null.
So, during a User creation, I would like 3 possibilities : leave the Player field empty, select an already-existing player, or create a new Player. At first I wanted to add a "Create new" option in the Player dropdown list, but have simply gone for a "Create new Player" checkbox.
The idea is, if the checkbox is checked, I would like to remove the Player dropdown list and add an embedded form to create a new Player. I have tried several events (PRE_SET_DATA, PRE_SUBMIT & co), but none seem to trigger according to a user input.
This is something that I would have done in JScript, but seeing how Symfony's a much different animal than pure php, I don't know how to do it. Any help or advice would be greatly appreciated !
You're on the right track there with PRE_SET_DATA and PRE_SUBMIT events.
You need to use JavaScript to reload form from server and Symfony form events to rebuild the form.
This is the documentation you're looking for: http://symfony.com/doc/current/cookbook/form/dynamic_form_modification.html
Unfortunately, Symfony's form component is pretty complicated, so there are no simple code examples you can just take and use it without going through this article.
Also reading Form Events documentation is helpful for deeper understanding.
I am starting to build an app, using Meteor, that includes user-populated company profiles (including both financial data and text). I will be looking into a datafeed for public company information but much of the information for private companies will be user-populated.
I know I will need to create a form for the user to fill in so that the company information will be captured by the database. However, can I make this same form available to the user to both display the data and to allow them to edit the data in the future? Or do I need to build a separate view using tables for this purpose? My preference is the former, just one screen to create and edit as needed.
Any examples of similar instances would be very appreciated.
Thank you.
This is less of a meteor specific question, rather a general web technology question. Meteor can provide the data in the template of course, and it can offer events to process data and insert/update this to a database. This is the same as any underlying architecture. The question is really how to approach the problem with HTML & JavaScript.
A couple of potential methods:
Write your HTML to display the content in its non-editable form. Then provide an edit button to switch mode. When clicking this button switch on 'contenteditable' for the elements you wish to be edited: http://html5doctor.com/the-contenteditable-attribute/
Also reveal a save button, then process the event through meteor. Use selectors to extract the fields by referencing either designated class names, data attributes or name attributes. It would also be a good idea to alter the appearance of editable elements with a background or outline. The disadvantage here is that it's slightly non-standard and you may have the need for more complex data-types like dropdowns or checkboxes etc.
Create view with a standard form HTML. Style it in a way that shapes the information primarily for display rather than editing, eg. hide form field borders. Provide an edit button that when clicked alters the CSS and reveals form field borders, also reveal/replace elements which need more complex controls like dropdowns, perhaps turn on field labels too and of course a save button. The disadvantage is slightly more complex CSS and JavaScript.
I am working on a web service built on ASP.NET MVC 4 and have run into some trouble figuring out how to manage a model after log in so that it is widely available to all action functions created in the back end.
For example) Let's say I have built a service that allows a user to log in and manage multiple databases. After he logs in he is redirected to a view that allows him to pick which database he would like to manage, which inherits the old layout. After he clicks on the database he wants to manage, the model of this database is passed to the index view of a manage controller which utilizes a different layout than before. All of the managing action links are coded in the layout but the model was passed to the index page. He needs the model to be available for all the ActionResults in the managing controller, but a model can't be passed to a layout, so this is where I'm stuck.
Does anyone know of any good references or guides on how I can utilize a model throughout a whole layout? Or something a long these lines? I'm not sure the technique I used for this problem was the best but I don't know how else to go about this. If anyone knows a better technique of going about this please let me know.
Thank you!
I am very new to Flex (started learning a couple of days back), I now have some understanding on how to create user interfaces with Flex and how to do MVC with Cairngorm and I really started liking it. But I am still lost with changing views using Cairngorm or entirely in Flex. Being a Java/J2EE developer for more than 10 years, it helps me understanding new technologies comparing it with Java. Typically in java world or in any MVC framework, the controller once got the updated modal it redirects or sets the new view to the user. Lets say once I added a new movie to movie database, I want to show the user a view Movie screen and when he deletes a movie I want to take user to list of all movies. The example which I have seen so far(including the diagram explorer) are just changing the modal values and the data is updating in the same view (using [Bindable]), but my question is how to change the view depending on the result or if it's a fault I want to take user to a different screen. How to do that in flex and in Cairngorm. Are there any best practices available and somebody please point me to right direction/resource. Thanks in advance.
The usual way to do this with Cairngorm is to put the data about the state of the application (eg. the screen the user is on) in the model too. You can, for example, use the ViewStack as the main container of the different parts of your application and bind it's selectedIndex to a variable in the model which will be used to control the screen that is displayed to the user. Putting it shortly - the state of the application is a reflection of the model.
You may also want to take a look at the Mate framework. We recently switched to Mate after using Cairngorm because we found it was a much easier framework to use and understand.
For your example, you would have a faultHandler event listener that would call whatever method you wanted in your model. You could easily use that to show or hide whatever you needed to.