Pages Navigation Menu

Coding is much easier than you think

Struts-2 Updates

Struts2 AngularJS integration

Posted by in Ajax, AngularJS, Struts-2 | 5 comments

  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 more

Pagination in Struts 2 using jQuery jTable plugin

Posted by in Ajax, jQuery, Struts-2

    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 more

AJAX implementation in Struts 2 using JQuery and JSON

Posted by in Ajax, jQuery, Struts-2 | 54 comments

    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 more

Autocomplete in Struts 2 using Jquery

Posted by in Ajax, jQuery, Struts-2 | 9 comments

  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 more

CRUD Operations in Struts 2 using jTable jQuery plugin via Ajax

Posted by in Ajax, jQuery, Struts-2 | 69 comments

    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 more

FieldError in Struts 2 Example

Posted by in Struts 2 Tutorial, Struts-2 | 6 comments

    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 more

Login Interceptor in Struts 2

Posted by in Struts-2 | 7 comments

  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 more

Interceptors in Struts 2

Posted by 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 more

GridView in Struts2 using jQuery DataTable via Ajax

Posted by in Ajax, jQuery, Struts-2 | 17 comments

  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 more

Struts 2 and Tiles Framework Integration

Posted by in Struts-2 | 2 comments

Struts 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