controller

Are PHP MVC Controllers implemented by url rewrite?

假如想象 提交于 2019-12-06 12:51:00
问题 The controller in a Java EE application may be represented by a servlet, which may be currently implemented using JavaServer Faces (JSF). But in PHP there is no such servlet,so I guess is it implemented by url rewrite? So that every request is directed to that controller? 回答1: It can be done with mod_rewrite but mostly in php there is a front-controller mechanisim which does all controlling through a single file. In this way, all controllers are specified in the url. See this for more

Limit access by Controller or by Model?

妖精的绣舞 提交于 2019-12-06 12:11:55
问题 I'm just starting to sketch up the base of a web-based system, and I would like the admin to have the possibility to limit access either by Controller or by Model. My problem is, I can't decide which one (or both?) of them I should go with. Any ideas? Pros/Cons? First I was leaning towards doing it in the Controllers, seeing as they "control" the flow of the system. But then, thinking that the access should probably be limited by the data it accesses, not the logical part of the system, I

php session flash message

五迷三道 提交于 2019-12-06 12:07:23
i'm tryning to create session flash message after redirection. i have Controller class class Controller { function __construct() { if(!empty($_SESSION['FLASH'])) foreach($_SESSION['FLASH'] as $key => $val) $this->$key = $val; } function __destruct() { $_SESSION['FLASH']=null; } } also i have Controller child class Home, where functions are run by route, like /Home/Index => public function index() class Home extends Controller { function __construct() { parent::__construct(); } public function index() { //where i want to display $this->message only once echo $this->message; // but $this-

When a javaFX's controller is not enough to display content, it will display “…” at the end?

白昼怎懂夜的黑 提交于 2019-12-06 10:32:56
问题 My question is that can I catch the event of display "..." ? ※ I mean does javaFX have a API to judge if the end of the content is replaced with "..."? In fact, the reason for my question is that now our testers want us to set a TIP on one controller(like Label) if it is only not enough to display. If the content is enough to display in the controller, we don't need to add a TIP then. 回答1: There's no easy way of telling if a text has been clipped. This clipping is done on Labeled objects, and

Add child view controller swift

做~自己de王妃 提交于 2019-12-06 09:59:03
问题 I m trying to add child view controller to a containerViewController Child are : AViewController BViewController CViewController I have no error but when i launch the app, i can swipe the screen, there is 3 section swiped but the A,B,C view controllers don't appeared.. This is my code, any idea ? import UIKit class ContainerViewController: UIViewController { @IBOutlet var scrollView: UIScrollView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the

Grails controller unit tests with Joda Time

北城以北 提交于 2019-12-06 09:32:12
Some of the controller tests that generate-all creates are failing when I have a domain object with a Joda LocalDateTime field. $ grails create-app bugdemo $ cd bugdemo $ grails create-domain-class Item Edit grails-app/domain/bugdemo/Item.groovy package bugdemo import org.joda.time.LocalDateTime class Item { String name // LocalDateTime opening static constraints = { name blank:false } } Add the following line to BuildConfig.groovy compile ":joda-time:1.4" Continue at the command line $ grails compile $ grails install-joda-time-templates $ grails generate-all bugdemo.Item $ grails test-app

How to access data sent by user using controller on Ruby on Rails

时光怂恿深爱的人放手 提交于 2019-12-06 09:28:51
问题 I have a problem saving data sent by a user and using it in my view file, and I can't find a solution in other topics. This is my code to select a date via a form: <%= select( 'resource', 'field', @benchmark.compositions.find(:all).collect {|u| [u.date_composition] }, :prompt => 'Selected date') %> This is my controller to get this selection: def sample_method @resource_field = params[:resource][:field] end And this is my line in the routes.rb file: match 'benchmark/sample_method/:resource/

How to perform Controller.destroy action asynchronously in rails?

淺唱寂寞╮ 提交于 2019-12-06 09:17:23
I can easily delete the entries of post synchronously in rails application by following code: views <% @post.each do |post| %> <tr> <td colspan="3"><%= link_to 'Destroy', post, :method => :delete, :confirm => 'Are you sure?', :class => 'btn btn-mini btn-danger' %></td> </tr> <% end %> Controller class def destroy @post = Post.find(params[:id]) @post.destroy respond_to do |format| format.html redirect_to(posts_url) } format.xml { head :ok } end end This works fine. How make this destroy process async . So, that I will not required to add route or refresh the page . Edit Adding more explanation

RSpec: how to set a controller's instance variable

ⅰ亾dé卋堺 提交于 2019-12-06 09:15:42
问题 I have a this method in my rails controller: def some_init_func # ... @inst_var = 1 # ... end and later on: do_something_with(@inst_var) How do I set this instance variable in RSpec? allow(controller).to receive(:some_init_func) do # ???? what goes here ???? end Muchas gracias :) 回答1: assign is an RSpec method available for view tests, but it's not supported for controller tests. Controllers are typically expected to set instance variables, so RSpec doesn't allow for setting them, but it does

Is it possible in playframework to override the default save action in the CRUD controller and redirect to list after

瘦欲@ 提交于 2019-12-06 09:08:42
I'm using Play framework's great crud module. The thing is I would like to do some special processing and validation before my object gets saved. So I created a save action in my CRUD controller. So far so good. But now after the object is saved I would like to render the list of objects just like the CRUD module was doing before I overrode its save action. How would I go about doing this? Here is my controller: package controllers.admin; import java.util.List; import models.Category; import controllers.CRUD; @CRUD.For(Category.class) public class Categories extends CRUD { public static void