Update data in html table without refreshing whole page - java

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/

Related

Pagination in JSP using DataTables

I am planning to implement pagination in my JSP using DataTables. I previously implemented it using DisplayTag Library but looks like it is getting old now. I couldn't find a good example or a resource about Datatables on how to do it in a JSP. I have a list of object in my JSP and intended to show 10 records per page. With DisplayTag I did it very easily but with DataTables I am not exactly sure if it is straight forward and the changes would just be in the JSP. I want some thoughts or if there is any other library out there to help accomplish my goal.
Thanks.
Go with this link.
DatabaleExample

jQuery and JSON to retrieve data from database in Java web app?

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/

how to start on using DataTable in Jquery

I am trying to learn Java and Javascript. Currently I following MVC, where i have servlets that will send data from a table to a JSP and I disply the data in table.
i am trying to make this table editable and create a good look and feel of the table using DataTable, however i am not sure how or where to start..Can someone please help me on this. I am a beginner and any simple example on on how to use DataTable would really help?
Thank you!
There are several examples here: http://datatables.net/examples/
Datatables is a great plugin if you want to show the data. But in my experience, it is not simple to interact with the server.. Like... add a new tr and create an instance on database using java. It is complicated this interaction.
In my experience, I would use primefaces datables: http://www.primefaces.org/showcase-labs/ui/datatableBasic.jsf;jsessionid=1si9n7bh9e6921gz0mj3w42ew3

Fetching data in small units instead of fetching at a time

I'm currently working on a Struts 2 application with Spring as backend with MySQL database.
Right now fetching 1000+ rows on page load.
I'm using tablesorter jquery plugin for displaying the results,sorting on click and pagination purpose.
But the page is taking lot of time to load and also it hangs in IE !!
Is there any easier way to do this like fetching required data from database as and when the user makes the selection like fetch first 10 rows,sorting data,etc.
Any ideas to make the application work faster are welcome !!
I couldn't tell from the docs if the plugin supported server-side paging or not, but that'd be one thing to consider. It was unclear if its paging plugin had any options for this.
Does the plugin's example with a thousand students crash under the same circumstance?

Dyanamic Graphs using jsf

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/

Categories

Resources