I am doing a Java web application project wherein it one of its purposes is to display all data from the database. It uses the Hibernate, Struts2 and Spring frameworks. However, I want the application to retrieve the data using jQuery and JSON. Would that even be possible?
How would I do that? And are there any tools needed to achieve that? I can't find any tutorials online. Hope someone could help! thanks.
Java script can be used in any HTML widgets. It is not necessary that should be spring , struts ,etc. ultimately all these frame works will spit the HTML outputs. So what you have to learn is how can you invoke a java script function in the HTML widget. For your refrence I would to give some example
<spring:bind path="accountForm.account.someData">
<SELECT name="<c:out value="${status.expression}"/>" size="1" onChange=dynDisplay();>
</spring>
So Here I am calling a method called dynDisplay() on selecting of the widget someData.like this you can call any function and perform any task using javascript or jquery.
Yes it is possible, and actually the best scope, i recommend you to read the following tutorials and examples and then come up with a solution:
To convert java objects to json and viceversa use Jackson
http://www.mkyong.com/java/how-to-convert-java-object-to-from-json-jackson/
A great tutorial on Spring MVC and Hibernate integration:
http://www.beingjavaguys.com/2014/08/spring-restful-web-services.html
To get a json response out of a web service with jquery
http://api.jquery.com/jquery.getjson/
Finally a simple Struts 2 and Spring integration example
http://www.mkyong.com/struts/struts-spring-integration-example/
Related
I am developing a simple project using spring and hibernate, and at the moment I need to update data in database and in html page without refreshing whole page. What ways can I accomplish this and what ways are best suited to the spring hibernate combination? Is it possible without using javascript?
You have to use AJAX and JQuery most of the time and you cannot do it just using java or something like that. Javascript has come to stage if you need to perform some database operations without refreshing the page. If you want to learn more about how it can be done using spring and hibernate you may look at this link:
http://www.javacodegeeks.com/2012/02/ajax-with-spring-mvc-3-using.html
or
http://fruzenshtein.com/spring-mvc-ajax-jquery/
we maintain online book shop using java wicket and it also have search function for finding books in MYSQL database. If someone search for "Fiction" in the search box, the results will contain metadata of each result. If a user click on title, it will take him/her to details page.
I have a requirement to add functionality of reviews box/form in the details page using spring. we do maintian 2 other websites which needs similar sort of work. So we decided to develope this feature as a small individual and re-usable application then integrate into java Wicket or ZEND framework.
what i need to do is:-
1) get details from the form like name, email and review information - JSP or HTML, JQUERY
2) show the entered review on the web page and post those details to MYSQL (update the reviews table in db) when form submitted. springREST
Is it really possible to accomplish using SpringREST? or is there any options for this?
can anyone give some ideas on this requirement how to do?
Sure you can do this. If you implement this new feature with javascript, you can include it to both frameworks. I would suggest you use a javascript framework like AngularJS or Bootstrap as they will make calling the rest service easier.
In addition you need to deploy your rest service as an application or bundle it with your existing application that contains the wicket app.
Here you'll find an example on calling rest service with AngularJS How to access the services from RESTful API in my angularjs page?
I want to use the Raphael Javascript framework to create some charts based on dynamic data coming from my Java web application. Is the only way to access this data from my web application through the use of hidden fields on my page which I can then lookup inside the Rapahel JS code?
A typical approach would be for the web application to send a JSON file which your javascript would use to drive the Raphael library.
Reference:
Using JSON in jQuery.
Ajax Tutorials
As Brock says above, then look at: http://www.highcharts.com/
Why reinvent the wheel? Unless you want the experience. Graphing is fun.
My requirement is I need to populate dyanamic graphs in a jsp page. I am using jsf for my project. I planning to use "jfreecharts" but dont know how to bind my jsp page with the back bean. I have some drop downs on the basis of the selection I my BackBean is fetching the data from the DB. Can you please suggest me some procedure to that with some sample code for my reference?
You can use Fiji (Exadel) library.
They have charts, as well as support for wrapping SWF elements and sending properties in JSF.
See an example here. For each component, there is source code as well so you can try it yourself.
Primefaces has a nice chart component as well.
Fiji is very nice but check out this http://www.fusioncharts.com/
Can someone point to jqgrid + java web app solution or especially with populating the grid and sending the form back to server. there are several php examples but nothing on java.
If you want to use some advanced tools like Spring, Hibernate and Maven here is the good example.
http://krams915.blogspot.in/2012/01/spring-mvc-31-jqgrid-and-spring-data_1887.html
EDIT:
See this, if you want to use plain Servlet and JSP. This is very basic example.
http://javahunter.wordpress.com/2010/12/07/jqgrid-example/
Here is one example on the web:
jqGrid Forum: how-use-jqgrid-in-jsp-server-one-example
If you are using struts2 there's a plugin which includes jqueryui and jqgrid components.
http://struts2-jquery.googlecode.com/