I need to navigate from one controller to another, so I’ve made one render method:
private static final String ACTION_SHOW_JUSTIFICANTE = "action=" + ServletContextKeys.SC_SHOW_JUSTIFICANTE;
@Autowired
private MyOtherController myOtherController;
@RequestMapping(params = ACTION_SHOW_JUSTIFICANTE)
public final String doRenderShow(ModelMap model, RenderRequest renderrequest, PortletSession portletSession) {
MyBean myBean = service.getBean();
model.addAttribute(ServletContextKeys.SC_BEAN, myBean);
return myOtherController.doRender(model, renderrequest);
}
The render method of the other controller:
@RequestMapping(params = ACTION_MY_OTHER_CONTROLLER)
public final String doRender(ModelMap model, RenderRequest renderrequest) {
if (!model.containsAttribute(ServletContextKeys.SC_BEAN)) {
model.addAttribute(ServletContextKeys.SC_BEAN, new MyBean());
}
//Do some stuff..
return ServletContextKeys.SC_VIEW_PAGE;
}
And it works fine, but the problem is about Date binding when I trying to display the bean values in the JSP:
<form:input id="registerDate" size="10" styleClass="input" path="registerDate" readonly="${imputado}"/>
The register date is shown whith this format: ‘Mon Oct 08 22:00:00 GMT 2012’ instead the needeed one: ‘dd/MM/yyyy’
I already have defined a initBinder method:
@InitBinder
public final void initBinder(WebDataBinder binder) {
//Date
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
dateFormat.setLenient(false);
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}
But, probably in this case, I’m not calling it (It actually works ok, in other normal cases)
Any ideas how to format this date and fix this issue..? Thanks!
It was my fault! Sorry, but the code is Ok. the problem was that the initBinder was defined just in one of the controllers.