Struts-2 Updates
Struts2 AngularJS integration
In this post, we will learn to implement AJAX calls from a JSP page to a Struts 2 Action class using AngularJS and update the same JSP page back with the Json response from the Struts 2. Library Required Since Angular can send and receive only in json format, to handle it you need struts2-json-plugin-2.x.x.jar. This plugin allows you to serialize the Action class attribute which has getter and setter into a JSON object. How to use? First of all create a “Dynamic Web Project” in Eclipse and...
read morePagination in Struts 2 using jQuery jTable plugin
This is the third article on jQuery jTable plugin in Struts 2 that describes on how to implement pagination feature to do server side paging in struts 2 using the JQuery jTable plugin and here I have not explained about how to setup jTable plugin in struts 2. So If you have not read my previous articles “Setting up JQuery jTable plugin in Struts 2” and “Ajax based curd operation in Struts 2 using JQuery jTables plugin”, I will recommend that you read that article first because first one explains how you...
read moreAJAX implementation in Struts 2 using JQuery and JSON
In this post, we will learn to implement AJAX calls from a JSP page to a Struts 2 Action class using JQuery and update the same JSP page back with the Json response from the Struts 2. Library required Since the response to be sent to jQuery is of type JSON, to handle it you need struts2-json-plugin-2.x.x.jar. This plugin allows you to serialize the Action class attribute which has getter and setter into a JSON object. Steps done to set up our action for JSON From the browser perspective:...
read moreAutocomplete in Struts 2 using Jquery
I have already written a detailed post on Autocompleter Textbox & dropdown in Struts 2 using struts2-dojo-plugin.jar. In this post, I am going to describe how to implement Ajax based autocomplete in Struts 2 web application using jQuery plugin. jQuery Autcomplete is part of the jQuery UI library which allows converting a normal textbox into an autocompleter textbox by providing a data source for the autocompleter values. Here when user types a character in text box, jQuery will fire an ajax request using autocomplete...
read moreCRUD Operations in Struts 2 using jTable jQuery plugin via Ajax
In the previous article “Setting up jQuery jTable plugin with Struts 2 framework” I have explained about how to setup jTable plugin in struts 2 application. This article describes on how to implement “Ajax based curd operation in Struts 2 using the JQuery jTable plugin, If you have not read the previous articles “Setting up jQuery jTable plugin with Struts 2 framework” I will recommend that you read that article first because it explains what jTable plugin is and how you can integrate it in Struts 2...
read moreFieldError in Struts 2 Example
In our previous tutorial we learnt about actionError and actionMessage in struts 2, in this tutorial, we are going to describe the fielderror tags. The fielderror tag is a UI tag that renders field errors if they exist. ** UPDATE: Struts 2 Complete tutorial now available here. Folder Structure Action Class Develop an action class using addFieldError(String fieldName, String errorMessage)method. This method adds an error message for a given field to the corresponding jsp page. Here the...
read moreLogin Interceptor in Struts 2
In our previous tutorial we have learned about concepts of interceptor and how interceptors gets execute before and after action class by creating a custom interceptor. In this article we shall create a custom LoginInterceptor which could be used in real time struts 2 application This LoginInterceptor will perform these tasks:- Check user exist in session or not. Runs before every action to check .If someone try to access direct URL of welcome page and if he is not present in session then it will redirect towards login...
read moreInterceptors in Struts 2
Interceptors are introduced as part of the Struts2 framework, power mechanism for controlling request and are responsible for the most of request processing. Interceptors are invoked by controller before and after invoking action and sits between the controller and action. An interceptor allows common, cross-cutting tasks to be defined into a clean, reusable component, which is different than the “action” code. Tasks like data validation, type conversion, and file upload are done using interceptors in...
read moreGridView in Struts2 using jQuery DataTable via Ajax
In this post, I am going to explain on how to use DataTable plugin to display data in Gridview format with pagination feature in Struts 2 web application. DataTable is a jQuery plugin which adds a lot of functionality to plain HTML tables, such as filtering, paging sorting, changing page length, server side processing etc. Library struts2-json-plugin-x.x.x.jar DataTable Plugin OpenCSV(Optional – I am using this to deal with a csv file as data source instead of database to keep it simple) jQuery UI themes In...
read moreStruts 2 and Tiles Framework Integration
Apache Tiles is a templating framework used to simplify the development of web application user interfaces. Tiles allow defining page fragments which can be combined into a complete page at runtime. These fragments, or tiles, can be used as reusable templates in order to reduce the duplication of common page elements or even embedded within other tiles. See the snapshot below. ** UPDATE: Struts 2 Complete tutorial now available here. Advantage of tiles framework Code reusability Easy to modify Easy to remove Jar...
read more