Review
In the previous section, we have created the Jasper report layout using iReport and learned where to place them on our Spring project. In this section, we will focus on the presentation layer and learn how to display data using HTML and jqGrid.Table of Contents
Part 1: Introduction and Functional SpecsPart 2: Java classes
Part 3: Jasper layout with iReport
Part 4: HTML and jqGrid
Part 5: XML configuration
Part 6: Running the Application
Presentation Layer
We will use jqGrid to display our data in an interactive table and jQuery to provide AJAX support.What is jQuery?
jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.
Source: http://jquery.com/
What is jqGrid?
jqGrid is an Ajax-enabled JavaScript control that provides solutions for representing and manipulating tabular data on the web. Since the grid is a client-side solution loading data dynamically through Ajax callbacks, it can be integrated with any server-side technology, including PHP, ASP, Java Servlets, JSP, ColdFusion, and Perl.
Source: http://www.trirand.com/jqgridwiki/doku.php
Preview
We only have a single HTML file (users.jsp, a JSP to be exact) to perform all actions. This page contains our jqGrid table and buttons for downloading reports in Pdf and Excel format.Source
At first glance, when you look at the JavaScript code, it is somewhat intimidating, but once you've familiarized with the jqGrid syntax, you'll find that it's actually simple. If you aren't familiary with jqGrid, please visit the jqGrid Official WikiYou might be asking: "What's that humongous lines of jibberish code?" If you'd been following my blog, you would notice that I have tackled jqGrid a couple of times from my previous tutorials. If my explanation in this tutorial isn't enough, please see the following tutorials for an alternative perspective:
- Spring MVC: Integrating MySQL, MongoDB, RabbitMQ, and AJAX - Part 1: jQgrid View
- jqGrid and Spring 3 MVC Integration Tutorial
- Spring 3: Dynamic MVC using jqGrid and MongoDB
An In-depth Look
If we partition this JSP page, you will notice the following sections:- URL imports
- JavaScript and CSS imports
- jqGrid initialization
- JavaScript functions: downloadXls(), downloadPdf(), download()
Pay attention to the download() function's algorithm:
1. Retrieve a download token via AJAX.
2. Store the token.
3. Show download progress dialog box.
4. Start actual download.
5. Do a periodic AJAX call to verify if token still exists. If not, hide download progress box.
- HTML table
Notice how we've separated the HTML markup from the JavaScript code. We could, of course, move that one huge JavaScript code in an external js file, and make the HTML look somewhat smaller. But I'll leave that exercise to my readers.
Next
In the next section, we will focus on the configuration files for enabling Spring MVC. Click here to proceed.
Share the joy:
|
Subscribe by reader Subscribe by email Share
"Great blog created by you. I read your blog, its best and useful information. You have done a great work. Super blogging and keep it up.php jobs in hyderabad.
ReplyDelete"
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeletecore java training in Electronic City
Hibernate Training in electronic city
spring training in electronic city
java j2ee training in electronic city
supreme outlet
ReplyDeletejordan 1
off white shoes
nike off white
jordan outlet
jordan shoes
hermes outlet
golden goose shoes
fear of god
jordan outlet