java - Play Framework 2.3.4 - How to call Results.badRequest() on a POST request and direct to method in controller not mapped by routes? -


OK It's a bit difficult to understand my title.

What am I trying to achieve?

My Controller:

  Public Fixed Results addSomething () {Return getSomething (SOME_FORM); } Public static results addSomething (form of & lt; SomeFormDetails & gt; someForm) {// Do complex things to get someObject and someOtherObject returned is OK (com.me.views.html.pages.AddSomething .render (someObject, someOtherObject , SomeForm)); } Public stable results postFromSomeForm () {form & lt; SomeFormDetails & gt; FillForm = SOME_FORM.bindFromRequest (); SomeForm Details Description = refresh.get (); // Check some if (database.adstaff (details)) {return redirect (com.me.controllers.routes.Get.index ()); } Else {// #### This important BIT #### // this is not possible as the next line (form of  someForm) // method // add / s is not possible in the map / /, But what you call me badRequest Return (com.me.controllers.routes.get.add something .render (fillForm)); // #### This is important ####}  

route

  get some com.me.controllers. Get addSomething ( ) Post / Something / Com.me.controllers.Get.postFromSomeForm () Adding  

What I want to avoid is having lots of unnecessary code to get the bar -Bar is someObject and someOtherObject under the postFromSomeForm () method.

I am aware that I can move a little shown by / am doing it SomeFormDetails & gt; / SomeObject and someOtherObject in some other way, but two things do not make it complicated due to the nature of the nature

I can add addSomething ; SomeForm) In the routes, if I change the name (overloaded methods are not allowed), but this is not desirable because it will cause many other problems.

I just can not change the important bit in:

  Change badRequest (com.me.controllers.Get.addSom ething.render (filledForm));  

Because it is not supported (i.e. without using reverse gate) FIIi gives it results in method (result) is not applicable for badRequest (content) argument (results) .

I am pretty sure that I am trying to get something easier but using this framework is not an easy way to achieve it because all the reversegate bits generated from the routes are due to controlling methods Do not return the same type of form (which I know is definitely the case and it understands it is necessary)

Can anyone tell me what to do? Shish is, it is a simple supported way to accomplish this? Please tell me that the question does not make sense.

You can get what you want to achieve, return the provided template instead of the action one Results of:

  Do the complex stuff to get public static string addSomething (form & lt; SomeFormDetails & gt; someForm) {// someObject and someOtherObject com.me.views come back . Html.pages.AddSomething .render (some objects, some other objects, someForm) .body (); } // later badRequest (com.me.controllers.routes.Get.addSomething.render (fillForm));  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -