Pages Navigation Menu

Coding is much easier than you think

Struts-2 Updates

Advertisements

Struts 2 + Spring Integration Example

Posted by on Jul 13, 2013 in Struts 2 Tutorial, Struts-2 | 0 comments

Struts 2 + Spring Integration Example

  In this following example we shall see how to integrate Spring and Struts 2 using the struts2-spring-plugin. We integrate Spring with Struts2 to utilize the Spring’s Dependency Injection feature. First add the org.springframework.web.context.ContextLoaderListener to the web.xml file.   ** UPDATE: Spring Complete tutorial now available here.   ** UPDATE: Struts 2 Complete tutorial now available here.   File : web.xml     <?xml version="1.0" encoding="UTF-8"?> <web-app...

read more

Struts 2 + Log4j integration example

Posted by on Jun 20, 2013 in Struts 2 Tutorial, Struts-2 | 0 comments

Struts 2 + Log4j integration example

  In this tutorial we will learn about integrate Log4j with Struts 2 framework.   Download It – Logger-Without Library files   Log4j Appender   Create a text file named “log4j.properties“, put it at the root of the project classpath. The log4j.properties or appender file is the Log4j configuration file, it defines how the Log4j logging mechanism work.   ** UPDATE: Struts 2 Complete tutorial now available here.   In this example, it will log all the logging detail and outputs it to an...

read more

How to exclude action methods from validation in struts2

Posted by on Jun 13, 2013 in Struts-2 | 3 comments

How to exclude action methods from validation in struts2

My Action class have the following methods, 1.addAction 2.deleteAction 3.updateAction 4.populateAction   ** UPDATE: Struts 2 Complete tutorial now available here.   Consider a scenario where I want to apply validation for addAction and deleteAction method alone and not for other method , then all you to do a configuration in struts.xml file by listing all the methods you don’t want to be run through the validation framework in the excludeMethods parameter. Since we only want addElement and deleteElement validated, list the...

read more

Setting up jQuery jTable plugin in Struts 2 framework

Posted by on Apr 19, 2013 in jQuery, jTable, Struts 2 Tutorial, Struts-2 | 42 comments

  In this article we will learn to setup jTable and dependent libraries in Struts 2 web application. jTable is a jQuery plugin which is used to create AJAX based CRUD tables without coding HTML or Javascript, to know more about jTable please refer the article here   Steps done to set up our application for jTable   Libraries required for the setup, jQuery jQuery UI jTable struts2-json-plugin-2.x.x.jar Commonly required Struts 2 jars   Now to start with demonstration of above topic, let us Create a Dynamic Web Project in...

read more

ModelDriven Interceptors in Struts 2

Posted by on Apr 18, 2013 in Struts 2 Tutorial, Struts-2 | 0 comments

ModelDriven Interceptors in Struts 2

  In our last article we have learned how to use a JavaBean class as a property in struts 2 action.   In this tutorial we will learn about Struts 2 support for model objects.   The Model object is a simple JavaBean object, which will be available to action class directly from ValueStack, i.e we dont need to do deeper referencing to refer its attribute(JavaBeans attribute).   To make a JavaBean object as a model object, our Action class should implement ModelDriven interface which forces the getModel() method to be...

read more

Types of Actions class in Struts 2

Posted by on Apr 18, 2013 in Struts 2 Tutorial, Struts-2 | 0 comments

    The functionality of the action class is to retrieve resource bundle, hold the data, provide validation, perform business logic and select the view result page that should be sent back to the user.   There are four different ways to write struts 2 action class , which are as follows   1. Action   For Struts 2 actions, it is not mandatory to implement any interface or extend any class. It is only required to implement execute() method that returns a string which is to be used in struts.xml, to indicate the result...

read more

ActionError & ActionMessage Example in Struts 2

Posted by on Apr 18, 2013 in Struts 1, Struts 2 Tutorial, Struts-2 | 5 comments

  In this tutorial we will learn about ActionError & ActionMessage class and its usage.     a) ActionError class is used to send error feedback message to user and it get rendered in jsp by using <s:actionerror/> tag.   b) ActionMessage class – is used to send information feedback message to user, and it get rendered in jsp using <s:actionmessage/> tag.   ** UPDATE: Struts 2 Complete tutorial now available here.   In this tutorial we will use the previous tutorials example to implement...

read more

Struts 2 Tutorial for beginners

Posted by on Apr 18, 2013 in Struts 2 Tutorial, Struts-2 | 34 comments

  Introduction to Struts 2 Framework   In this course we will learn how to use Struts 2 to create an MVC based Java web application. Struts 2 is a framework for developing MVC based web applications in Java. When building a complex web application it is often difficult to keep business and view logic separate from each other. In this course we will learn how to create a Java based web application using the Struts 2 MVC framework to cleanly separate our views from business logic. We will cover important features of Struts 2 like...

read more

Handling double form submissions in Struts2

Posted by on Apr 12, 2013 in Struts-2 | 5 comments

Handling double form submissions in Struts2

  Double form submissions(either by refreshing or by hitting the browser back button) can be irritating and in some cases leads to big problem .Luckly struts2 has a build in functionality that prevents such scenarios :<s:token/> tag and token interceptor. As an example, let’€™s say that we have a form that looks like this:   <s:form action="someAction"> <s:textfield key="key"/> <s:textfield key="otherKey"/> <s:textfield...

read more

An overview of Struts 2 field validators

Posted by on Apr 12, 2013 in Struts-2 | 0 comments

An overview of Struts 2 field validators

  Struts 2 comes with a validation framework part of which are field validators that cover a wide range of validation cases-from required field validation to regular expression validation.In this tutorial we will overview some of the build-in and most frequently used field validators. As an example consider the case where we have a registration form with fields that require most of the build-in validators. 1) String length validator Validates that field’s value length is between the values defined by its minLength and maxLength...

read more
%d bloggers like this: