model-view-controller

Where does input validation belong in an MVC application?

非 Y 不嫁゛ 提交于 2019-12-20 10:24:32
问题 I have a MVC application that receives an input from a form. This is a login form so the only validation that is necessary is to check whether the input is non-empty. Right now before I pass it to the model I validate it in the controller. Is this a best practice or not? Does it belong to the model? 回答1: I don't think there's an official best practice limiting validation to any single part of the MVC pattern. For example, your view can (and should) do some up-front validation using Javascript

facebook-C#-sdk MVC “Hello World” app - how to get access token?

拜拜、爱过 提交于 2019-12-20 10:24:13
问题 I've downloaded the C# Facebook SDK "Simple MVC Website Example" from CodePlex at: http://facebooksdk.codeplex.com/releases/view/54371 and have successfully got it to authenticate to my test Facebook app. But I can't quite work out how to get the access token (and I'm going to want offline access, so I only need to grab that token once, when the user first authorizes my app to grab their feed data). Many thanks 回答1: You will want to do two things. First, to request offline_access, you need to

securing the source code in a node-webkit desktop application

安稳与你 提交于 2019-12-20 10:14:09
问题 first things first , i have seen nwsnapshot. and its not helping. i am building an inventory management system as a desktop app using node-webkit . the project being built is using compoundjs (mvc javascript library). which have a definite folder structure (you know mvc) and multiple javascript files inside them. the problem is nwsnapshot allows the app to have only a single snapshot file but the logic of application is spread over all the folders in different javascript files. so how do i

Where to place business logic in Symfony2?

醉酒当歌 提交于 2019-12-20 09:49:16
问题 After reading a lot of posts and Stack Overflow resources, I've still got some problems about the famous question about "where to put business logic?" Reading StackOverflow Question and A Blog Post, I believe I've understood the issue of code separation well. Suppose I have a web form where you can add a user that will be added to a db. This example involves these concepts: Form Controller Entity Service Repository If I didn't miss something, you have to create an entity with some properties,

ASP.NET MVC - Model binding a set of dynamically generated checkboxes - how to

倖福魔咒の 提交于 2019-12-20 09:41:42
问题 I'm trying to model bind a set of dynamically generated checkboxes so as to process them in the controller action but can't get the model binding to occur. This is the scenario: My ViewModel class (DocumentAddEditModel) contains a dictionary (Dictionary<string,bool>) with the string of each entry being the name/label for each checkbox and the boolean indicating whether the checkbox is checked: public class DocumentAddEditModel { ... private Dictionary<string, bool> _categoryCheckboxes = new

Rails 3 how do I use link_to to change the value of a boolean in the db?

邮差的信 提交于 2019-12-20 09:40:09
问题 I'm trying to create a simple link that will allow an admin to approve a user on my website quite similar to what this guy was trying : In Rails 3 how do I use button_to to change the value of a boolean? Here's how it was supposed to work : Admin clicks the link to approve a user The link calls the activate function in UsersController The active function calls that users model the user model updates the approved attribute to true and saves it and here's how I was going to do it in my users

Where to determine UIView size

梦想与她 提交于 2019-12-20 09:12:33
问题 Summary: How should the UIViewController know the size of its UIView instance when initialising that view? The dedicated initialisation method for an UIView is the initWithFrame:(CGRect)frame method. This sets the frame for the newly created UIView. This method could be called from the UIViewController's loadView method, if that view controller's view is requested. The documentation of UIViewController states with respect to subclassing and view size: When creating the views for your view

How does Joomla Model View Controller (MVC) work?

£可爱£侵袭症+ 提交于 2019-12-20 09:04:21
问题 I am new to Joomla, I want to know how the Joomla controller passes data to the model, model to controller and controller to view. Although this might be a silly question, I really tried to find the answer. I hope I can get some help from the stackoverflow family. 回答1: The controller picks up the view variable in the url and using these determines which view needs to be used. It then sets the view to be used. The view then calls the model to fetch the data it requires and then passes this to

ASP.NET MVC - Partially updating model from view

北城以北 提交于 2019-12-20 09:02:19
问题 I just wondered how people were approaching this situation. It's something that seems like a weak point in my usage of MVC with ORMs (NHibernate in this case)... Say you have a fine-grained and complicated entity in your model. You will likely have an admin page to manage objects of this type. If the entity is complicated, it is unlikely that you will be modifying the whole entity in one form. You still need to pass the relevant properties to the view, and incorporate changes to those

MVC Pattern in JavaFX With Scene Builder

≡放荡痞女 提交于 2019-12-20 08:50:02
问题 I'm new to JavaFX and am struggling to create a proper MVC architecture given my current setup. I clicked together a UI using Scene Builder and designated a Controller class. Startup: public class Portal extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { Parent root = FXMLLoader.load(getClass().getResource("PortalUI.fxml")); stage.setTitle("Portal"); stage.setScene(new Scene(root)); stage.show(); } } And