Posts

Showing posts from May, 2013

STRUTS ACTION - AGGREGATING ACTIONS IN STRUTS

If you are a Struts developer then you might have experienced the pain of writing huge number of Action classes for your project. The latest version of struts provides classes using which you can aggregate a related set of actions into a single unified action. In this article we will see how to achieve this. Struts provides four important classes for this purpose. These classes are called as Dispatchers. The important Dispatchers that struts provides includes :   DispatchAction ,   ActionDispatcher   ,   LookupDispatchAction   and MappingDispatchAction . All these classes can be found in the package   org.apache.struts.actions . Let us look in to each of these in detail. Our examples use the simple CRUD actions. DispatchAction:   In this type of aggregation, the action class must extend DispatchAction class as shown. public final class CRUDDispatchAction extends DispatchAction { public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest reque

Struts MappingDispatchAction Example

Image
Struts MappingDispatch Action   (org.apache.struts.actions.MappingDispatchAction) is one of the Built-in Actions provided along with the struts framework. The   org.apache.struts.actions.MappingDispatchAction   class is a subclass of org.apache.struts.actions.DispatchAction   class. This class enables a user to collect related functions into a single action class. It  needs to create multiple independent actions for each function. Here in this example you will learn more about Struts MappingDispatchAction that will help you to grasp the concept better. Let's develop a class    MappingDispatch_Action   which is a sub class of  org.apache.struts.actions.MappingDispatchAction   class. This class does not provide an implementation for the   execute()   method because  DispatchAction   class itself implements this method.    MappingDispatchAction  class is much like the DispatchAction class except that it uses a unique action corresponding to a new request   ,   to dispatch th

Hibernate Criteria Query Example

The Criteria interface allows to create and execute object-oriented queries. It is powerful alternative to the HQL but has own limitations. Criteria Query is used mostly in case of multi criteria search screens, where HQL is not very effective.  The interface org.hibernate.Criteria is used to create the criterion for the search. The org.hibernate.Criteria interface represents a query against a persistent class. The Session is a factory for Criteria instances. Here is a simple example of Hibernate Criterial Query:   package  roseindia.tutorial.hibernate; import  org.hibernate.Session; import  org.hibernate.*; import  org.hibernate.cfg.*; import  java.util.*; /**   *  @author  Deepak Kumar   *    * http://www.roseindia.net  Hibernate Criteria Query Example   *     */ public class  HibernateCriteriaQueryExample {    public static void  main(String[] args) {    Session session =  null ;    try  {    // This step will read