Hi,
I'm trying to fetch the records to grid using <kendo:dataSource-transport> and i get 406 error i'm setting the contentType="application/json", not sure what else i'm missing.l pls suggest. I followed the same process as given in spring demo.
My Jsp:
<%@taglib prefix="kendo" uri="http://www.kendoui.com/jsp/tags"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<c:url value="/retrieveCandidateList/update" var="updateUrl" />
<c:url value="/retrieveCandidateList" var="readUrl" />
<form:form method="post" action="retrieveCandidateList.html">
<kendo:grid name="grid" dataBound="gridDataBound">
<kendo:grid-editable mode="inline" confirmation="Are you sure you want to remove this item?"></kendo:grid-editable>
<kendo:grid-columns>
<kendo:grid-column title="Row Number" field="rowNum" width= "100px" />
<kendo:grid-column title="Work Request Seq" field="wrkRqstSeq" width="130px"/>
<kendo:grid-column title="Test Package Id" field="tstPkgId" width="230px" />
<kendo:grid-column title=" " width="180px">
<kendo:grid-column-command>
<kendo:grid-column-commandItem name="edit" />
<kendo:grid-column-commandItem name="destroy" />
</kendo:grid-column-command>
</kendo:grid-column>
</kendo:grid-columns>
<kendo:dataSource>
<kendo:dataSource-schema>
<kendo:dataSource-schema-model id="wrkRqstSeq">
<kendo:dataSource-schema-model-fields>
<kendo:dataSource-schema-model-field name="rowNum" type="string" editable="false" />
<kendo:dataSource-schema-model-field name="wrkRqstSeq" type="string" editable="false" />
<kendo:dataSource-schema-model-field name="tstPkgId" type="string" editable="false" />
</kendo:dataSource-schema-model-fields>
</kendo:dataSource-schema-model>
</kendo:dataSource-schema>
<kendo:dataSource-transport>
<kendo:dataSource-transport-read url="${readUrl}" dataType="json" type="POST" contentType="application/json" />
<kendo:dataSource-transport-update url="${updateUrl}" dataType="json" type="POST" contentType="application/json" />
<kendo:dataSource-transport-parameterMap>
<script>
function parameterMap(options,type) {
return JSON.stringify(options);
}
</script>
</kendo:dataSource-transport-parameterMap>
</kendo:dataSource-transport>
</kendo:dataSource>
</kendo:grid>
My controller:
@Controller
@SessionAttributes("data")
public class ListCandidateController
{
@Autowired
ListCandidateService listCandidate;
Log logger = LogFactory.getLog(this.getClass());
@RequestMapping(value = "/retrieveCandidateList", method=RequestMethod.POST)
public @ResponseBody List<WorkRequest> retrieve(@ModelAttribute("data") WorkRequestdata, BindingResult result, HttpServletResponse response) throws Exception
{
response.setContentType("application/json");
System.out.println("In controller - read method");
List<WorkRequest> databaseList = listCandidate.retrieveData(data);
System.out.println("list size:" +databaseList.size());
return databaseList;
}
17 Answers, 1 is accepted
I was able to load data in Grid using local data (using http://demos.telerik.com/jsp-ui/grid/local-data-binding). However, i have problem with implementing inline editing with this. Demo for inline editing shows with <kendo:dataSource-transport>. I'm using Spring MVC.
The error code indicates that the server can't satisfy the Accept headers set by the client.
In this case you're likely to see the following headers being sent:
Accept:text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01
In the context of Spring MVC this might mean that Jackson is misconfigured. In this case it might refuse to return JSON.
Is the answer on SO relevant for your scenario?
Regards,
T. Tsonev
Telerik
Here are the jsp's i'm using....and My controller has this method:
@RequestMapping(value = "/retrieveList")
@ResponseBody
public List<WorkRequest> retrieveCandidate(@ModelAttribute("data") WorkRequest data, BindingResult result) throws Exception
{
System.out.println("In controller - read method");
List<WorkRequest> databaseList = XXX.retrieveData(data);
System.out.println("list size:" +databaseList.size());
return databaseList;
}
I'm using Spring3.2.4 and jackson jars jackson-annotations-2.1.1.jar, jackson-core-2.1.1.jar,jackson-databind-2.1.1.jar, jackson-core-asl-1.9.13.jar, jackson-mapper-asl-1.9.13.jar. Also, my servlet context has
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:annotation-config />
<mvc:annotation-driven/>
Not sure what else i'm missing here.
Thanks for sharing the headers and all the extra info.
Is the request initiated by submitting the form? I can't quite wrap my head around this, but I'm certain it doesn't make sense to submit the grid as part of the form.
Do you get a request to the service if you don't submit the form?
Regards,
T. Tsonev
Telerik
I'm not submitting the grid as part of the form submission. First, i have a jsp page to enter the query param and upon form submission,i get the list from the service method and display that list using grid in jsp.
Also, I tried an other approach using GSON library with this i was able to convert to JSON,but the view is not using the kendo jsp wrapper its just displaying the coverted json string. plz advice if i'm missing anything here.
Please accept my apologies for the delayed response.
I see, what you describe makes sense and should work fine.
Can you please share the headers for the request to the actual service (/retrieveList)?
The previous headers were for the request for the actual page and that led to a bit of confusion on my side.
Regards,
T. Tsonev
Telerik
Please find the request header for the list page
After inspecting the screenshot it appears that the provided request headers are the same as the previous ones. From this point a better way to investigate the issue would be providing runable example where the issue is reproduced - could you please provide it?
Regards,
Vladimir Iliev
Telerik
While i get the runnable example.I've an other question. Will i be able to implement inline editing for grid data populated using local data binding like this
<kendo:dataSource data="${products}" pageSize="20">
<kendo:dataSource-schema><kendo:dataSource-schema-model><kendo:dataSource-schema-model-fields><kendo:dataSource-schema-model-field name="productName" type="string" /><kendo:dataSource-schema-model-field name="unitPrice" type="number" /><kendo:dataSource-schema-model-field name="unitsInStock" type="number" /><kendo:dataSource-schema-model-field name="discontinued" type="boolean" /></kendo:dataSource-schema-model-fields></kendo:dataSource-schema-model></kendo:dataSource-schema></kendo:dataSource>
I don't see why inline editing won't work for this data source definition.
Feel free to include this in the sample as well.
Regards,
T. Tsonev
Telerik
please add Kendo js , styles to GridSample\WebContent\js and GridSample\WebContent\styles folders as these are removed in the attached zip as the max size for the attachment is 2mb. Also, please include the jars below in the GridSample\WebContent\WEB-INF\lib
jackson-annotations-2.2.2.jar
jackson-databind-2.2.2.jar
jackson-core-2.2.2.jar
kendo-taglib-2014.3.1411.jar
spring-beans-3.2.4.RELEASE.jar
spring-context-3.2.4.RELEASE.jar
spring-context-support-3.2.4.RELEASE.jar
spring-core-3.2.4.RELEASE.jar
spring-expression-3.2.4.RELEASE.jar
spring-web-3.2.4.RELEASE.jar
spring-webmvc-3.2.4.RELEASE.jar
Sorry, I couldn't quite get the project running. I needed a few more JARs (commons-digester, catalina), but that wasn't enough.
I'll give it another shot on Monday.
Please, feel free to open a support ticket in the meantime.
The file attachment size is 20MB there and you shouldn't have problems attaching the full project there.
Regards,
T. Tsonev
Telerik
Hi,
I have opened a support ticket(Ticket No: 975680) and attached the full running sample project there.
Thanks
We'll continue the discussion there based on the actual project.
Regards,
T. Tsonev
Telerik