Thymeleaf Pagination Url Failed to Convert String to Long - spring-mvc

So I'm trying to paginate results where I have a page with a path variable, and the Thymeleaf th:href keeps telling me Failed to convert value of type 'java.lang.String' to required type 'java.lang.Long'
So I added an object called "StudySet" to the model in my controller method, like this
modelAndView.addObject("studySet", studySetById);
And then I try to use it in a th:href in my HTML like this
th:href= "#{${studySet.id}/?page=} + ${page}"
But my URL just shows up like this
http://localhost:8080/studySet/$%7BstudySet.id%7D/?page=2
When I want it to look like this
http://localhost:8080/studySet/8/?page=2
8 is the id of the "studySet" object.
So if anyone has any idea on what I'm doing wrong and could let me know, that would be awesome, thanks.

ok, I reproduced your problem and here is a solution:
th:href= "#{{studySetid}/?page={page}(studySetid=${studySet.id},page=${page})}"
here is a reference for further reading

Related

I am trying to enter a formatted chunk of code as a custom field but it never makes it to the database

I am trying to pass this into a custom field called "_vtprd_includeOrExclude"
a:2:{s:23:"includeOrExclude_option";s:11:"includeList";s:29:"includeOrExclude_checked_list";a:2:{i:0;s:2:"1856";i:1;s:4:"1857";}}
I am using WPAllImport to get the data out of an XML package and into the field.
I know that the function works because if I put "bob" in the custom field it goes in without any issue.
What is wrong with this string that is causing it to come up empty?
As always, your feedback and help is greatly appreciated.
The problem was that the data within the string would fail if turned into an array because the string count was incorrect for one of the fields.
The part to look at is at the end.
... a:2:{i:0;s:2:"1856";i:1;s:4:"1857";}}
The offender is i:0;s:2:"1856"
"1856" is 4 string characters long, not to.
So it SHOULD look like this.
i:0;s:4:"1856"
When I made that change I silenced the custom function and it worked just fine.
Perfect example of not knowing enough about how this structure works. So I guess knowing is half the battle.
go joe.

highcharts prepare options for POST

I need to send a Highcharts options object to an asp page so it can be written to a json flat file. These files are later passed to phantomjs via highcharts-convert in order to create some pdfs.
The problem however is stringifying the objects. I keep getting this error:
Uncaught TypeError: Converting circular structure to JSON
when I try this:
$.post("myASP.asp", JSON.stringify(myChart.highcharts().options));
There is a sample POST string here http://docs.highcharts.com/#render-charts-on-the-server but I'm not sure how to achieve that with mine. When I paste their sample into my code for testing I get all kinds of unescaped double quote errors. Is that a typo on their part?
I would check if there are curricular references in the JSON objects. As far as I remember that is not supported by the JSON serializer.
One example of this if you have an object with an array of children that refer back to the parent.
I think you can try the following:
{"infile":myChart.getSVG()}
This should get the svg representation of the chart

parsing simple xml with jquery from asp.net webservice

I'm breaking my head over this for a while now and I have no clue what I do wrong.
The scenario is as followed, I'm using swfupload to upload files with a progressbar
via a webservice. the webservice needs to return the name of the generated thumbnail.
This all goes well and though i prefer to get the returned data in json (might change it later in the swfupload js files) the default xml data is fine too.
So when an upload completes the webservice returns the following xml as expected (note I removed the namespace in webservice):
<?xml version="1.0" encoding="utf-8"?>
<string>myfile.jpg</string>
Now I want to parse this result with jquery and thought the following would do it:
var xml = response;
alert($(xml).find("string").text());
But I cannot get the string value. I've tried lots of combinations (.html(), .innerhtml(), response.find("string").text() but nothing seems to work. This is my first time trying to parse xml via jquery so maybe I'm doing something fundemantally wrong. The 'response' is populated with the xml.
I hope someone can help me with this.
Thanks for your time.
Kind regards,
Mark
I think $(xml) is looking for a dom object with a selector that matches the string value of XML, so I guess it's coming back null or empty?
The First Plugin mentioned below xmldom looks pretty good, but if your returned XML really is as simply as your example above, a bit of string parsing might be quicker, something like:
var start = xml.indexOf('<string>') + 8;
var end = xml.indexOf('</string>');
var resultstring = xml.substring(start, end);
From this answer to this question: How to query an XML string via DOM in jQuery
Quote:
There are a 2 ways to approach this.
Convert the XML string to DOM, parse it using this plugin or follow this tutorial
Convert the XML to JSON using this plugin.
jQuery cannot parse XML. If you pass a string full of XML content into the $ function it will typically try to parse it as HTML instead using standard innerHTML. If you really need to parse a string full of XML you will need browser-specific and not-globally-supported methods like new DOMParser and the XMLDOM ActiveXObject, or a plugin that wraps them.
But you almost never need to do this, since an XMLHttpRequest should return a fully-parsed XML DOM in the responseXML property. If your web service is correctly setting a Content-Type response header to tell the browser that what's coming back is XML, then the data argument to your callback function should be an XML Document object and not a string. In that case you should be able to use your example with find() and text() without problems.
If the server-side does not return an XML Content-Type header and you're unable to fix that, you can pass the option type: 'xml' in the ajax settings as an override.

How do I identify the referrer page in ASP.NET?

In VS2003, I am trying to find out the particular page where the request is coming from. I want to identify the exact aspx page name.
Is there a way to only get the page name or some how strip the page name?
Currently I am using the following instruction...
string referencepage = HttpContext.Current.Request.UrlReferrer.ToString();
and I get the following result...
"http://localhost/MyPage123.aspx?myval1=3333&myval2=4444;
I want to get the result back with out any query string parameters and be able to identify the page MyPage123.aspx accurately...
How do I do that??
Instead of calling .ToString on the Uri, use the AbsolutePath property instead:
string referencepage = HttpContext.Current.Request.UrlReferrer.AbsolutePath;
This should get you "/MyPage123.aspx" in your case.
Edit: Had LocalPath instead of AbsolutePath by mistake
Look at the Segments property of the URI class (which is what HttpContext.Current.Request.UrlReferrer returns).
Something like HttpContext.Current.Request.UrlReferrer.Segments[1] (changing the 1 indexer to get the correct segment you require).

getautosuggestdata type is not supported

I am using Google AutoSuggestData. It's implemented fine and working in a page
but when trying to implement in another page it gives error
system exception :getautosuggestdata
type is not supported
It looks like you forgot to include the DataType property when including the control in the new page. If you set a value that it doesn't recognise, you get an exception like "getautosuggestdata type 'Foo' is not supported", so I guess the error see is what will happen when the property is empty.

Resources