controller

Overloading Controller Actions

删除回忆录丶 提交于 2020-01-03 08:38:15
问题 I was a bit surprised a few minutes ago when I tried to overload an Action in one of my Controllers I had public ActionResult Get() { return PartialView(/*return all things*/); } I added public ActionResult Get(int id) { return PartialView(/*return 1 thing*/); } .... and all of a sudden neither were working I fixed the issue by making 'id' nullable and getting rid of the other two methods public ActionResult Get(int? id) { if (id.HasValue) return PartialView(/*return 1 thing*/); else return

Type error: Argument 1 passed to Doctrine\Common\Collections\ArrayCollection::__construct() must be of the type array, object given

*爱你&永不变心* 提交于 2020-01-03 06:01:14
问题 Actually... more or less I know where is my problem. I'm receiving this error in a particular controller where I try to persist($object) ... Actually I'm developing a webapp for me to have a register to all my books I'm reading.. and I use Google Books API for that. So, I have the next Entities: Admin Users Books Categories I was thinking about the db and I wanted a table with user_id, book_id so I decided to do a ManyToMany but, I don't know if this is the way.. or not. (Because my familiars

Yii url manager only ID in url

不羁的心 提交于 2020-01-03 04:24:08
问题 i have in YII for example domain: www.example.com/product-url-1234 how to set rules in urlManager and how to use controller/action/id 回答1: If you want to use this url www.example.eu/product-url-1234 and suppose 'index' is the name of the action of the 'user' controller that will handle the request Then create a rule like '<id:.*?>'=>'user/index' Now if you will use Yii::app()->createUrl('user/index',array('id'=>'product-url-1234')) then it will give you the desired result. And if you Visit

Symfony 2 sharing data between controllers

六月ゝ 毕业季﹏ 提交于 2020-01-02 13:27:14
问题 I have started to create a project using Symfony 2. I need to share data between all controllers. I have added a base controller which extends symfony\controller and each of my controllers extends this base controller class BaseController extends Controller class HomeController extends BaseController This base controller will be used for things like assigning global twig variables ( I know I can do this in the config but some of the variables will be gotten from other config files and

How to make two posts with different contents in GrailsIntegrationTesting

戏子无情 提交于 2020-01-02 09:28:34
问题 I'm testing a controller, and I cannot make two posts with different contents. Follows an example, in which I execute a post to the cardController, with some data (post1, with json1). Then, I execute another post, with different data (post2 with json2). But I cannot make the second post succesfully, because I've seen (debuggin the application), that the json in the request, is json1 again, and not josn2. So, how can I make two different posts in the same test? void testSomething(){ def json1

Python: Unable to solve a differential equation using odeint with signum function

[亡魂溺海] 提交于 2020-01-02 06:52:21
问题 I am trying to solve this problem: where U is here: s=c*e(t)+e_dot(t) and e(t)=theta(t)-thetad(t) and e_dot(t)=theta_dot(t)-thetad_dot(t) where thetad(theta desired)=sin(t)-- i.e signal to be tracked! and thetad_dot=cos(t),J=10,c=0.5,eta=0.5 I tried first with odeint- it gave error after t=0.4 that is theta(solution of above differential equation) fell flat to 0 and stayed thereafter. However when I tried to increase mxstep to 5000000 I could get somewhat correct graph till t=4.3s. I want to

Controller Action Methods with different signatures

我们两清 提交于 2020-01-02 06:41:49
问题 I am trying to get my URLs in files/id format. I am guessing I should have two Index methods in my controller, one with a parameter and one with not. But I get this error message in browser below. Anyway here is my controller methods: public ActionResult Index() { return Content("Index "); } public ActionResult Index(int id) { File file = fileRepository.GetFile(id); if (file == null) return Content("Not Found"); else return Content(file.FileID.ToString()); } Update: Done with adding a route.

SpringMVC Ajax validation

蓝咒 提交于 2020-01-02 05:17:47
问题 I have a Spring Mvc 3 form that POST to a controller, in the controller i make calls to execute DML statements. I also have a separate validation class that implements Validator and is called in my Controller. I do both simple and complex validation in there like check if user name exist and return an error message if it exist. I would like to use ajax to validate only the user name field when i tab out of the field on the view, but i would like to make a call to the already implemented

What's the correct place to share application logic in CakePHP?

走远了吗. 提交于 2020-01-02 03:26:12
问题 I guess simple answer to the question would be a component . Although I agree, I feel weird having to write a component for something so specific. For example, let's say I have a table of users. When a user is created, it should form a chain reaction of events, initiating different kinds of data related to the user all around the database. I figured it would be best to avoid directly manipulating the database from different controllers and instead pack all that neatly in a method. However

System.Web.Mvc.Controller Initialize

你。 提交于 2020-01-02 02:24:08
问题 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 from BaseController, and it will redirect them if a certain value is true. However, this code does not work!!! The call to RedirectToAction is made, but after the Initialize method