advertisement
javaboutique
Search Tips
Articles  |   Tutorials  |   Reviews  |   Tools  |   by Category  |   by Date  |   by Name  |   Submit  |   Source  |   Forums  |  
javaboutique
Browse DevX


Partners & Affiliates











advertisement

Adding Spice to Struts

Reviews : Adding Spice to Struts :

The Road Map…

Our Solution 2 demands some manipulation of the Struts framework components. Hence, we decided to trace how the declarative form bean configuration is mapped to the form bean objects within the Struts layer. We have done a dissection of the Struts and the following facts were laid before us.

  • Struts uses the Commons Digester component of the configuration files.
  • The Commons Digester component relies on a set of rules to be passed to it in order to parse the configuration file. Struts passes a ConfigRuleSet object to the Digester component.
  • The ConfigRuleSet object contains all the parsing rules.
  • For the form bean configuration Struts uses a class called FormBeanConfig.
  • The framework initialises any particular form bean class by calling its initialize() method. Within the initialize() method each particular FormBean class gets hold of its own FormBeanConfig object, obtains all the properties and….
  • Dynamic Action Form classes(DynaActionForm etc.) gets all the properties from the FormBeanConfig object and puts them in a Map.

These facts again opened at least two possible solutions. But we soon realized the potential risks associated with each of them.

Working Out the Kinks

Now we pretty much have an idea of what to do. Our first reaction was to come up with a form-bean declaration like this:


  <form-bean name="someForm" type="org.apache.struts.action.DynaActionForm" includes=”anotherForm”>

In this mode of declaration, the form-bean "someForm" will include all the properties declared in the form-bean "anotherForm". This is exactly what we wanted. However, we raised that in order to implement this solution we need to do the followings:

  • The ConfigRuleSet class already declares rules by which we can capture any attribute defined for the <form-bean> tag. This is good news.
  • However, The Ruleset Also Defines That The Defined Attributes Must Correspond To The Instance Variables Of The Formbeanconfig Class. For Example, There Are Two Attributes "Name" And Type" In The ≪Form-Bean≫ Tag And The Formbeanconfig Class Also Defines Two Instance Variables Called "Name" And "Type". The Digester Component Sets The Values Of These Instance Variables To The Attribute Value Specified In The Configuration File By Invoking The Corresponding Set() Methods In The Formbeanconfig Class.
  • Thus, to accommodate another attribute for the <form-bean> tag, we need to extend the FormBeanConfig class.
  • Moreover, there is no easy way to attach a custom FormBeanConfig class to the framework. The only alternative is to create a new RuleSet class, which defines the rules for parsing the <form- bean> definition by specifying the alternative FormBeanConfig class.
  • Thus, we need to create a new RuleSet class.
  • Additionally, we raised that in the initialization process of the form bean, we need to read all the properties of another form bean defined in the "includes" attribute and put them into the map of the original form bean. For example, the initialization process should put all the properties of the "anotherForm" form bean in the Map of the form bean "someForm".
  • In order to achieve this, we need to extend the existing DynaActionForm and override the initialize() method to do the job.

By carefully weighing the work involved, we decided that it is certainly an overkill to create a new FormBeanConfig class and a new RuleSet class. But in all the cases, we need to come up with a new FormBean class to override the initialize() method.

How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.

 Microsoft Visual Studio 2010 Showcase
 Avaya Developer Showcase
 MSDN Spotlight
 PHP for Windows Showcase
XML error: undefined entity at line 39
advertisement
Receive Articles via our XML/RSS feed
Receive Articles via our XML/RSS feed

JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for Windows 95, 98, ME, NT, 2000 and XP. It's designed to automatically optimize your Windows settings, boosting your Internet connection up to 200%.

Windows 7: From Beta to Final Code in One Year
Google Shows Off Chrome OS, Releases Source
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?
Fedora 12 Takes Aim at Linux Networking
Top Supercomputer Nearly Doubles in Speed
Fedora 12 Linux Tackles Virtualization
Apple Gives iPhone Developers App Status Tracker
Novell Sets OpenSUSE 11.2 Free

Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Exploring HTML 5's Audio/Video Multimedia Support
Overriding Virtual Functions? Use C++0x Attributes to Avoid Bugs.
Understanding the Cloud Computing Security Vulnerabilities
Cisco and IBM Target a Greener World
Upgrade to Visual Studio 2010 with the Ultimate Offer

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs