controller

Static Classes in Servlet

I make static classes in servlet, these classes are controllers for web pages. Requests are redirected to controllers by controller urls that are in static HashMap that contains all controllers. Are there any posibilities that user/session realted stuff could get messsed up with other users sessions? I will of course save all session rel...

accessing lang variables from controller + codeigniter

Hi Friends, How can I access my lang variables in controller? function index() { $seo_title = $this->lang->line('blablabla'); $data['page_title'] = $seo_title; $this->load->view('contact/index.php',$data); } in my lang file blablabla has string in, and it works well when I call from view file. but when I want to call fro...

help with rails render action vs routing

I was using some image cropping example that I found online and now I got confused. There is actually no "crop" method in my controller. Instead (following the guide) I put a render :action => 'cropping', :layout=> "admin" In my create method. That renders a page the view called cropping.html.erb . It works fine but I have no idea h...

Zend Framework, what $this->_forward is doing

Hello everyone, I would like someone to explain me what _forward is exactly doing, I cannot see if _forward is also rendering the attached view to the action or just executing the action. Also is it possible to pass argument to $this->action in a view script ? More generally my problem is how to code a confirmation page, let's say t...

Rails Functional Test of Arbitrary or Custom URLs

I have a RESTful resource in my Rails app called "Photo". I'm using Paperclip to serve different "styles" of my photos (for thumbnails and the like), and I'm using a custom route to RESTfully access those styles: map.connect "photos/:id/style/*style", :controller => "photos", :action => "show" That's working fine, but I want to write ...

Is controller-based class loading better? (CodeIgniter/KohanaPHP/etc..)

If you have worked with some of the frameworks like CodeIgniter or KohanaPHP, then you probably have seen that they are built so that the controller loads everything. Therefore, if you are in a library and wish to load additional resources you must get a copy of the controller instance and then use that to load the additional classes. $...

Using parameters in my controller

So I'm using the excellent Ancestry gem But while the documentation seems very complete I don't understand how to pass the parameter of my element which I want to be the parent of my newly created element. Firstly, do I want to do it in the new or create action... allow me to explain. For example: (with some actions removed for brevity) ...

Controllers in the context of Composite WPF

What is a Controller in the context of Composite WPF? ...

Should a view be dependent on its controller? (ASP.NET MVC)

Hi all, Have a question about the design/usage of asp.net mvc here. In the html helper class, you can get to the current controller by Html.ViewContext.Controller. Moreover, you can get to the request, route collection and much more from the html helper class. Doesn't this go against the rule of MVC? Doesn't this opens up a ways for...

Running a premade bulletin board through my Front Controller in Zend

Hi all, I tried to ask this once, but I think that my former question was too unclear for you guys to answer, so I'll try again I'm making a website using the Zend Framework, and am trying to include the premade messageboard Phorum. So far, I've made it work by not running it through my bootstrap using my .htaccess file. What I'd li...

How can I test an event of a MVC controller

I want to test the OnException, OnActionExecuted event of an MVC controller. If I use mock like this: var httpContext = MockRepository.GenerateMock<HttpContextBase>(); var request = MockRepository.GenerateMock<HttpRequestBase>(); httpContext.Expect(c => c.Request).Return(request).Repeat.AtLeastOnce(); r...

System.Web.Mvc.Controller Initialize

Hi, i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (something == true) RedirectToAction("DoSomething", "Section"); base.Initialize(requestContext); } } Basically, all my controllers will derive f...

Unit test a controller with custom model binder

In my application I have a custom model binder that I set to the DefaultBinder in the global.asax: ModelBinders.Binders.DefaultBinder = new XLDataAnnotationsModelBinder(); When writing unit tests for controllers I need to make sure the controller uses the custom model binder but I don't know how to do this. My test looks like this: ...

Cakephp: how to access to model "variables" (mapped from db) from the controller after a set?

Ok i have this controller: class ExampleController extends AppController { var $name = 'Example'; public function test_me () { $this->Example->Create(); $this->Example->set( 'variable_from_db_1' => 'random_value_1', 'variable_from_db_2' => 'random_value_2' ); //here, how can i...

In Grails, how to invoke a controller action from a g:select

I'm using a g:select (actually, a g:currencySelect) in my view. I want a controller action to fire as soon as the user changes the value in the resulting select box. How can I do this? ...

registering event listeners in a controller

I'm working on creating a simple MCV application, in order to understand MVC better. The problem I'm having is registering event listeners. The way I see MVC is that the view dispatches events, the controller listens for these events and acts on them, either updating the model or amending the view. So in my MVC app I have a controller wh...

How to generate and transmit a JavaScript variable from MVC Controller?

I'm trying to fill a JSON object with a list of items from the database when the page first loads. This list of items comes from the database. Right now, I've strongly typed the View and am looping through the list of items to build an HTML unordered list, and then in the JavaScript building the JSON object from what's been output in the...

How to test custom messages thrown back by a models validation in Rails

I have this validation in my user model. validates_uniqueness_of :email, :case_sensitive => false, :message => "Some funky message that ive cleverly written" In my tests I want to ensure that when a user enters a dupe email address that my message definately gets shown but without having to duplicate the error string from abov...

Accessing ASP.NET MVC Model Data from external Javascript file

Hi, I'm trying to use JQuery's $.getJSON to access Model data from the Controller, and build a JSON object in the javascript to use as the user adds and removes items from a list. All JS is done in an external file. The hit to the server for the Model data is done only once after the page first loads so I can get the full list of option...

How can I check if a controller was called using post or get?

In ASP.Net MVC, how can I check in a controller method, if it was called using post or get? I am aware I can limit methods to being called only by post or by get - but how can I check for post/get in a method that allows both? ...