Spring Portlet Jquery Ajax post json dateTime conversion error -
this question related to:
spring portlet jquery ajax post controller
i'm submitting form jquery ajax spring portlet mvc controller. issue starttimestamp , endtimestamp datetime in pojo. json sends string , conversion not happeinng. error is:
systemout o 14:10:16.040 [webcontainer : 2] debug org.springframework.beans.beanutils - no property editor [org.joda.time.datetimeeditor] found type org.joda.time.datetime according 'editor' suffix convention ... systemout o error::failed convert property value of type 'java.lang.string' required type 'org.joda.time.datetime' property 'starttimestamp'; nested exception java.lang.illegalstateexception: cannot convert value of type [java.lang.string] required type [org.joda.time.datetime] property 'starttimestamp': no matching editors or conversion strategy found
i can't edit pojo , add @datetimeformat because pojos generated xsd. tried adding customobjectmapper, nothing works. appreciated.
function addnew() { var startdateele = $('#start_date').val(); var starttimeele = document.getelementbyid("start_time"); var starttime = starttimeele.options[starttimeele.selectedindex].value; var startdate = new date(startdateele + ' ' +starttime); var enddateele = $('#end_date').val(); var endtimeele = document.getelementbyid("end_time"); var endtime = endtimeele.options[endtimeele.selectedindex].value; var enddate = new date(enddateele + ' ' +endtime); var dataobject = { 'starttimestamp': startdate, 'endtimestamp': enddate, 'description': $('#0_message').val(), 'active': $("input[name=status]:checked").val() }; $.ajax({ url: "<%=addnewurl%>", type: 'post', data: dataobject }).done(function(json){ console.log(json); //alert("json::"+json); alert("success!"); }).fail(function() { alert("oops! error occured while processing request. please try again after sometime."); }); }
controller:
@resourcemapping(value = "addnewurl") public void addnew(@modelattribute(value = "dataobject") custobj n, bindingresult bindingresult, resourcerequest request, resourceresponse response, modelmap model) throws exception { if (!bindingresult.haserrors()) { ... } }
please help
i able solve issue adding controller. main reason had was portlet mvc , couldn't add annotation pojo generated xsd:
@initbinder public void initbinder(webdatabinder binder) { binder.initdirectfieldaccess(); /* register appropriate date editor */ string dateformat = "eee mmm dd yyyy hh:mm:ss 'gmt'z"; binder.registercustomeditor(datetime.class, new datetimeeditor(dateformat, false)); }
Comments
Post a Comment