model-view-controller

Laravel 5: The difference between Auth::guard($this->getGuard())->login($user); and auth()->login($user);

旧巷老猫 提交于 2020-01-14 22:54:04
问题 What is the difference between: Auth::guard($this->getGuard())->login($user); and auth()->login($user); ? For example, in PasswordController.php we can have: protected function resetPassword($user, $password) { $user->password = $password; $user->save(); Auth::guard($this->getGuard())->login($user); } or protected function resetPassword($user, $password) { $user->password = $password; $user->save(); auth()->login($user); } (in this case, we create a mutator in Users.php to bcrypt password AND

What is the correct way of Message Passing between Classes in MVC?

倾然丶 夕夏残阳落幕 提交于 2020-01-14 14:57:27
问题 public void Model { private SwingPropertyChangeSupport spcs; public void updatedb(); public void addPropertyChangeListener(PropertyChangeListener listener) } public void Gui { private JFrame view; Gui() { view = new JFrame(); init();// for initilizing ui components EventQueue.invokeLater(new Runnable() { @Override public void run() { try { view.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } void addListener(ActionListener a); void init(); void updateGUI(); } public

Action that refreshes the current page

允我心安 提交于 2020-01-14 14:02:27
问题 I want to create an action in a Rails controller that does something in the db and then just refreshes the current page. Example: Controller: A Views: A, B. controller A is the following: def action1 somethingToTheDB end view A is the following: -html- -body--link to action 1--/body- -/html- view B is the following -html- -body--link to action 1--/body- -/html- If I come to action 1 from view A I want to refresh view A, if I come from view 2 I want to refresh view 2. Is that possible without

Java Swing GUI design techniques for user actions validations (MVC-FSM)

旧城冷巷雨未停 提交于 2020-01-14 09:38:10
问题 I have implemented GUIs using Swing and always tried to follow the MVC pattern as much as I could. I was wondering though, if MVC is not the only part of the puzzle. Are FSMs used in GUI's design as well? I have never used an FSM in a GUI and my approach was: on action, the corresponding method of the controller was called, to endup updating the model, finishing with updating the view. Usually upon a request triggered by a user's action I used some simple checks to make sure that the user

Dependency Injection vs. Managed Dependencies vs. Global Object

◇◆丶佛笑我妖孽 提交于 2020-01-14 09:24:11
问题 I'm working within a Javascript + BackboneJS (an MVC framework) + RequireJS framework, but this question is somewhat OO generic. Let me start by explaining that in Backbone, your Views are a mix of traditional Views and Controllers, and your HTML Templates are the traditional MVC Views Been racking my head about this for a while and I'm not sure what the right/pragmatic approach should be. I have a User object that contains user preferences (like unit system, language selection, anything else

Hard-coded @RequestMapping URL in Spring MVC Controller

巧了我就是萌 提交于 2020-01-14 08:43:26
问题 I'm studying Spring 3 and I'm using it in a simple web-application. Now I'm implementing a Spring MVC Controller using annotations, and I'm wondering: Is there any best practice using @RequestMapping annotation? I mean: I've seen that usually the URL mapped in this annotation is hardcoded in the class... Is there a way to pass the URL in a 'loosely coupled way' (to obtain a more reusable class)? I know that there are some wild cards that can be used, but I think that isn't the solution... Am

Angularjs templating: model and function stop working in external templates?

久未见 提交于 2020-01-14 06:32:08
问题 After this question, I am facing another challenge, the model and function inside the $scope seem have stopped working. Below is the test code, the Add button seem does not collect any data I input from <input type='text' ng-model='newPerson' /> anymore, html, <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>AngularJS</title> <meta charset="utf-8"> <script src="js/jquery-1.10.1.min.js"></script> <script src="js/angular.min.js"></script> <script src="js

rails has_one relationship causing problems - also white screen

孤街浪徒 提交于 2020-01-14 05:45:07
问题 I have two models: Schedule and Project. Schedule belongs_To Project and Project has_one schedule. There are several problems, but i think they all have the same cause. Here is the code for the schedules#create controller: def create @schedule = Schedule.new(schedule_params) @schedule.project = Project.find(params[:project_id]) if @schedule.project.student_id == current_user.id if @schedule.save && @schedule.freelancer_accepts flash[:notice] = "Successfully created schedule." redirect_to

PHP MVC - How can Controller and View access same instance of Model?

独自空忆成欢 提交于 2020-01-14 05:18:07
问题 I'm developing my own PHP MVC for a database application, which I'd already completed but using monolithic classes that do everything - MySQL processing, input processing and display. It works great but it's a nightmare to debug and to make alterations! I've recently discovered MVC's and in the process of rewriting the app - it's all on the drawing board at the moment so I haven't actually got any code to share with you. There's one thing I'm stumbling on: I've got it that the Controller

Simple Search Form in Rails 3 App not Displaying

六月ゝ 毕业季﹏ 提交于 2020-01-14 03:49:07
问题 I ran through railscast #37 and can't seem to even get my search form to display on my index page. Any ideas whats wrong with my code? thanks in advance! any help is greatly appreciated. Here is the index page where the form is located: <h1>All users</h1> <% form_tag users_path, :method => 'get' do %> <p> <%= text_field_tag :search, params[:search] %> <%= submit_tag "Search", :name => nil %> </p> <% end %> Heres the controller: class UsersController < ApplicationController ... def index