Hi Chris,
I want to call the post method of my dynamic plugin via following client side view:
<form action="/app/spring/examplecontroller" method='post'>
<div class='new-row'>
<select class='form-control' name="hotelName">
<option>Select Your Hotel</option>
<option>The Leela Palace,Bangalore</option>
</select>
</div>
<div class='new-row'>
<div class='in-bl-2'>
<input type='text' class='form-control chk-in' placeholder='25-09-2015' name="chkInDate"/>
</div>
<div class='in-bl-2'>
<input type='text' class='form-control chk-out' placeholder='27-09-2015' name="chkInOutDate" />
</div>
</div>
<div class='new-row'>
<div class='in-bl-3'>
<select class='form-control' name="rooms">
<option>Rooms</option>
<option>1</option>
</select>
</div>
<div class='in-bl-3'>
<select class='form-control' name="adults">
<option>Adults</option>
<option>2</option>
</select>
</div>
<div class='in-bl-3'>
<select class='form-control' name="childrens">
<option>Children</option>
<option>1</option>
</select>
</div>
</div>
<div class='new-row'>
<input type='submit' class='btn' value='Check Availability' />
</div>
</form>
I uploaded my dynamic plugin, it is working correct but the problem is , when I call the POST method , it is being called along with the call GET method 3 times in total repeatative 4 times the request is going how to control that method , here is my controller and giving the messages regarding GET method,
package com.dotmarketing.osgi.spring;
import com.dotmarketing.util.Logger;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
/**
* Created by Jonathan Gamba
* Date: 6/18/12
*/
@EnableWebMvc
@Configuration
@RequestMapping ("/examplecontroller")
@Controller
public class ExampleController {
@RequestMapping(method = RequestMethod.GET, produces={"application/json","application/xml"}, consumes="text/html")
public ModelAndView helloWorld() {
Logger.info( this.getClass(), "Received request to hello" );
String myMessage = "Hello World,GET Spring 3.1 and dotCMS!";
// This will resolve to /application/spring/helloworld.dot, and put the String myMessage in the map with key "message"
return new ModelAndView("helloworld", "msg", myMessage);
}
@RequestMapping(method = RequestMethod.POST,produces={"application/json","application/xml"}, consumes="text/html")
public String helloWorldPost(Model model) {
Logger.info( this.getClass(), "Received request to hello1" );
String myMessage = "Hello World,POST Spring 3.1 and dotCMS!1";
// This will resolve to /application/spring/helloworld.dot, and put the String myMessage in the map with key "message"
model.addAttribute("msg",myMessage);
return "helloworld";
}
@RequestMapping(value = "/{userName}", method = RequestMethod.GET)
public String getHello(@PathVariable String userName, Model model) {
Logger.info( this.getClass(), "Received request to hello user" );
// set the message
String aMessage = (userName != null)
? "Hello EDIT " + userName + ", welcome to Spring 3.1 and dotCMS! "
: "Hello Total Stranger, welcome to Spring 3.1 and dotCMS! ";
// Attach message to the Model
model.addAttribute("message", aMessage);
// This will resolve to /application/spring/helloworld.dot
return "helloworld";
}
}
here is the log file generated;-
2015-10-08 11:47:08,741 INFO com.dotmarketing.business.DotGuavaCacheAdministratorImpl - *** Building Cache : csscache, size:100, toDisk:true,Concurrency:32
2015-10-08 11:56:43,578 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello1
2015-10-08 11:56:43,686 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 11:56:43,900 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 11:56:43,900 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 11:59:00,662 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello1
2015-10-08 11:59:00,736 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 11:59:00,957 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 11:59:00,960 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:00:41,037 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello1
2015-10-08 12:00:41,114 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:00:41,410 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:00:41,411 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:01:03,205 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello1
2015-10-08 12:01:03,290 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:01:03,500 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:01:03,500 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:01:41,897 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello1
2015-10-08 12:01:41,969 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:01:42,145 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:01:42,145 INFO com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:09:44,543 INFO com.dotmarketing.business.ajax.PermissionAjax - ##=> permissionMap: {inode=5e6aaea0-60f7-4c07-82e9-34cdcac67972, roleId=654b0931-1027-41f7-ad4d-173115ed8ec1, permission=15, id=12490, type=individual, isBitPermission=true}
2015-10-08 12:09:44,543 INFO com.dotmarketing.business.ajax.PermissionAjax - ##=> permissionMap: {inode=5e6aaea0-60f7-4c07-82e9-34cdcac67972, roleId=999cd6bf-5cef-4729-8543-696086143884, permission=1, id=12442, type=individual, isBitPermission=true}