Pages Navigation Menu

Coding is much easier than you think

Struts-2 Updates

Struts2-Jfreechart integration

Posted by in JFreeChart, Struts-2 | 3 comments

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 more

Introduction to Struts 2 Framework

Posted by in Struts-2

  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 more

How to use a JavaBean class as a property in struts 2 action class.

Posted by in Struts-2

How 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 more

Displaytag export option is not working- Solution

Posted by in Java, Struts 1, Struts-2 | 3 comments

Displaytag 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 more

Model 1 and Model 2 (MVC) Architecture

Posted by in Java, Servlet, Struts 1, Struts-2 | 2 comments

Model 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 more

How to Override Default Theme in Struts 2 ?

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

  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 more

Changing default style of s:actionerror / s:actionmessage tag

Posted by in Struts 2 Tutorial, Struts-2

    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 more

How to get checkbox values from struts2 checkbox in displaytag to action class

Posted by in Display Tag, Struts 2 Tutorial, Struts-2 | 3 comments

How 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 more

Struts 2 tag not working in Display tag – Solution

Posted by in Display Tag, Struts 2 Tutorial, Struts-2

Struts 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 more

Concept of Servlets Vs Concept of Struts 2

Posted by in Java, Servlet, Struts 2 Tutorial, Struts-2 | 4 comments

  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