Struts-2 Updates
Struts2-Jfreechart integration
In this article we will learn to integrate Struts 2 with JFreeChart using struts2-jfreechart-plugin-x.x.x.jar for creating a pie chart in web application using JFreeChart library. The JFreeChart is easiest and the most widely used library for creating a wide variety of good looking charts. The Struts-JFreeChart plugin allows Struts 2 Actions to easily return generated charts and graphs. Instead of streaming a generated chart directly to the HTTP response, this plugin provides a ChartResult, which handles the generation for you....
read moreIntroduction to Struts 2 Framework
In our last article we have learned about the difference between Model 1 and Model 2 (MVC) Architecture. In this article we will learn about Struts 2 framework and about the Architecture which it follows. In general if you are about to build a standard application using JSP and Servlets, then you will end up in a following MVC pattern. ** UPDATE: Struts 2 Complete tutorial now available here. Why web Framework ? Web framework is a basic ready made underlying of MVC structure, where you have to just...
read moreHow to use a JavaBean class as a property in struts 2 action class.
In this tutorial we will learn how to use a JavaBean class as a property in struts 2 action. Consider a scenario, in which you have written an action class, which in turn has a JavaBean class as its property as shown below. ** UPDATE: Struts 2 Complete tutorial now available here. Action class HelloAction.java package com.simplecode.action; import com.opensymphony.xwork2.Action; import com.simplecode.bo.User; public class HelloAction implements Action { private User user; public User...
read moreDisplaytag export option is not working- Solution
In this article we will learn to resolve the issue which occurs while exporting the file using display tag, In order to enable export functionality in display tag, configure display tag in JSP as shown below. <display:table name="studentList" pagesize="5" export ="true" requestURI="/displaytag.jsp"> <display:column property="rollNo" title="Roll No"/> <display:column property="studentName" title="Student...
read moreModel 1 and Model 2 (MVC) Architecture
Misconceptions Student: Master, what is the difference between MVC 1 and MVC 2 ? Master: Grasshopper, there is no such thing as MVC 1 and MVC 2, there’s just MVC. if you meant to ask about the difference between Model 1 and Model 2 with respect to web applications, then this article will help you out. In Java there are two types of programming models Model 1 Architecture Model 2 (MVC) Architecture ** UPDATE: Struts 2 Complete tutorial now available here. Model 1 Architecture Flow of...
read moreHow to Override Default Theme in Struts 2 ?
Struts 2 have theme generation functionality due to which it automatically generates Table based HTML code for its tags. This is due the default theme (x_html) ** UPDATE: Struts 2 Complete tutorial now available here. Other themes are simple css_xhtml ajax You can change this theme setting to any other theme on tag level, page level or application level as shown below. 1. Tag Level <s:submit name="clear" action="ClearFormAction" value="Clear" theme="simple"...
read moreChanging default style of s:actionerror / s:actionmessage tag
In struts 2 when you use <s:actionerror /> tag, it displays the errors with bullets, On viewing the page source of the jsp page, we can see that error message is displayed using <ul> <li>error 1</li> <li>error 2</li> </ul> But suppose if our requirement is to display the error message without bullet in the action errors or action messages ** UPDATE: Struts 2 Complete tutorial now available here. There are 2 ways to solve this problem 1....
read moreHow to get checkbox values from struts2 checkbox in displaytag to action class
Consider a scenario, such that we have a list of items and each item can be selected by checking its checkbox. If a submit button is clicked after selecting all necessary checkboxes. So now, in our Action class, we could get the values of checkboxes which had been selected, by which we can implement delete functionality. ** UPDATE: Struts 2 Complete tutorial now available here. The following snippet of code is used to retrieve the value from a checkbox used inside displaytag. <display:table...
read moreStruts 2 tag not working in Display tag – Solution
Consider a scenario, such that you want to display a value of a column based on certain condition. For example: if a student’s marks is greater than 50 display as ‘pass’, if its less than 50 then display as ‘fail’. For this scenario, in a display tag, most of us result in the following code snippet. <display:table name="ranklist" id="row" pagesize="10" requestURI="rankAction" > <s:if test="%{mark >...
read moreConcept of Servlets Vs Concept of Struts 2
In our previous article we have created a hello world program in struts2, in which I have passed parameter from request and setted in action class via a member variable, which may led you in some confusion, since in case of servlets the member variable in it are shared between all request and only those variable inside doget and dopost methods remains unique. So inorder to know why a member variable in struts 2 remains unique per request, we have look into the conceptual difference between Servlets and Struts 2. This article deals with...
read more