model-view-controller

MVC - Model - View Model Structure

故事扮演 提交于 2019-12-25 00:46:58
问题 Quick question, having a look around it seems this is the case, but it seems a bit like code-duplication to me, which I see as a waste of time. This is an object in my Model layer, so outside of my MVC project, separate all together. public class MyObject { public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string EmailAddress { get; set; } } But then, inside of my MVC project, i'm supposed to have as a ViewModel class? public class

When to use a singleton?

旧时模样 提交于 2019-12-25 00:42:31
问题 I have this code: class MyController { public function newUserAction() { $view = new View('myfrontend'); if($this->request->isPost()) { $form = new MyForm; $posts = $this->request->getPosts(); if($form->isValid($posts)) { //... } } $view->display(); } } So, everytime the form is not filled in correctly, the process starts again and so every time there is a "new View('myfrontend')" ect. But is that a good thing? To have a new view object again and again and again. Ain't it better to work with

call controller in JavascriptMVC

纵饮孤独 提交于 2019-12-25 00:40:52
问题 I have two controllers, init : jQuery.Controller.extend('App.Controllers.Init', { onDocument: true },{ load: function() { //call App.Controllers.Tabs on $('#tabs') //it is not that easy as $('#tabs').tabs() -> Throws: Object doesn't support this property or method } }); And tabs : jQuery.Controller.extend('App.Controllers.Tabs,... How to call tabs in init? 回答1: You need to: $('#tabs').app_tabs() Just cut the "controller" word out. Make all letters lowercase, and change dots "." to "_" One

Insert @Html.TextAreaFor onclick of a button (jQuery) OR using AJX.ActionLink

风格不统一 提交于 2019-12-25 00:29:34
问题 I have an edit form with @Html.TextAreaFor controls. I need to have a link 'Add New' which will insert a new @Html.TextAreaFor control at the end of the current display. Should it be @Html.TextArea control? If so, how should I fetch the information from newly created controls when I submit the form to save it to the DB? @model ResourceTemplate @using (Html.BeginForm()) { @Html.AntiForgeryToken() <div class="form-horizontal"> <h4>ResourceTemplate</h4> <hr /> @Html.ValidationSummary(true, "",

Using converters in a list with Spring Roo

时光怂恿深爱的人放手 提交于 2019-12-25 00:29:14
问题 Now that I found how to use converters in an HTML SELECT in Spring Roo, I am trying to do the same in a list. I managed to register a Converter in my ApplicationConversionServiceFactoryBean, but now I need to use it as well when displaying a list of my envities. I have the following entity : @RooJavaBean @RooToString @RooEntity public class Environment { @NotNull @Size(min = 2, max = 30) private String name; @ManyToOne private Application application; } When displaying it as a list in the

adding action listeners to a new jbutton created in a loop in java and called from another class

你说的曾经没有我的故事 提交于 2019-12-24 22:20:11
问题 I am trying to add an ActionListener to a JButton created in a loop, then call the ActionListener from another class (the controller class), but its not working. I don't know why. Here is the first class public class Browse extends JPanel { private JButton play_lists_btn; public Browse() { int increment = 0; while (increment < 5) { add(createButton(increment)); increment++; } } private JButton createButton(final int i) { play_lists_btn = new JButton(); play_lists_btn.setText(" This is " + i);

How to bind table data with ArrayList from thymeleaf to controller class

与世无争的帅哥 提交于 2019-12-24 20:56:04
问题 I am trying to achieve below process in thymeleaf ( I am new to thymeleaf ) 1. Import csv file and display to user 2. After displaying data to user , User will have option to update those data in DB Currently I am facing issue while passing table object to controller class GET @RequestMapping(value = "/samplepage", method = RequestMethod.GET) public String bulkupload(Model model, HttpSession session) { AccountService wlaccservice = new AccountService(); //ArrayList<AccountService>

call a service layer function in Listener class on Session destroyed in Spring

我与影子孤独终老i 提交于 2019-12-24 20:46:34
问题 I have one listener configured in web.xml <listener> <listener-class>com.Mylistener</listener-class> </listener> MyListener.java has following code public class MyListener extends HttpSessionEventPublisher{ myServiceInterface myService; @Override public void sessionCreated(HttpSessionEvent event) { super.sessionCreated(event); } @Override public void sessionDestroyed(HttpSessionEvent event) { //Call a method from service layer which is communicating with DAO layer and then database. super

Why is this view template expected?

蹲街弑〆低调 提交于 2019-12-24 20:45:44
问题 I have a controller method to authenticate a user who has received a link with a token (see method at the bottom). I have an integration test: def test get login_path('invalid token') // Login_path routes to the controller method below. assert flash[:danger] assert_redirected_to root_path end This test produces the following error (referring to get login_path('invalid token') ): ActionView::MissingTemplate: Missing template invitations/login, application/login with {:locale=>[:en], :formats=>

Firebase for MVC based projects

喜夏-厌秋 提交于 2019-12-24 20:32:39
问题 I'm struggling with Firebase due to it's asynchronous behavior. Let me explain what problem I'm facing As you know in MVC we do logic in our Controller, and then pass the output or data to the VIEW. But using Firebase we can't pass data to the view because Controller will not wait for Firebase response and will initialize the VIEW. class Controller{ index(){ var data = getDataFromFirebase(); // controller will not wait for this return view('users', data); } } So how we can handle this