DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • How To Design Reliable IIoT Architecture
  • What Is Test Pyramid: Getting Started With Test Automation Pyramid
  • Chaining API Requests With API Gateway
  • Tomorrow’s Cloud Today: Unpacking the Future of Cloud Computing

Trending

  • How To Design Reliable IIoT Architecture
  • What Is Test Pyramid: Getting Started With Test Automation Pyramid
  • Chaining API Requests With API Gateway
  • Tomorrow’s Cloud Today: Unpacking the Future of Cloud Computing

Task Driven vs Event Driven on Struts 2 Action

Ronald Daniel user avatar by
Ronald Daniel
·
Jun. 02, 12 · Interview
Like (0)
Save
Tweet
Share
5.92K Views

Join the DZone community and get the full member experience.

Join For Free

i had a job to design and develop a new framework for my own development team. we made the decision that we will adopt the struts 2 as my mvc framework.

yes i see the benefit from struts 2 very well, easy to implement and has so many features. until, my team member said “hey, i hate struts very much,  because i have to put many exception-handling and/or debugger inside many events/methods. can we use another framework? or just use the servlet mixed with the scriptlet?”

well i know his concern, it would be easy to read and maintain the code with their exception-handling when your code was still small, but along with the time, you will have your own trouble to maintain the code to stay in a good shape, believe  me, i have had this kind of experience before.

so, i think and try to find a better solution and lucky for me, i found the much better solution with the task-driven approach. maybe for some of you this approach will look like a tricky, but no problem as long as my team could gain a benefit from it and keep the code stay in healthy shape :) .

well, as a brief introduction for struts 2. this action code,perhaps, is the common way that almost every single struts 2 developer will do. as you can see, you can have many methods that indicates as an “event”

as you can see, i have the events/methods execute(), save(), fetch(), and delete() .

and you can see on the above code, that you have to do the exception-handling four times, one each method.  for me — and team — one is more than enough, easy to read and maintain the code, especially when exception occur.

now, my approach is to convert the familiarity of the event-driven into the task-driven.  so, i just have to add a new parameter that i gave name task , as a flagging parameter. in here i will have only 4 tasks to subtitute the 4 methods, “ execute “, “ save “, “ fetch ” and “ delete “.

implementing the code is easy, just put one extra attribute on the action code, i named it task.

and on the jsp, only add a minor change, and i will give you the comparison between the event-driven and task-driven .

as you can see the difference between those 2 slices of code. i dont know how about you, but i love the task-driven struts more than the event-driven. maybe it’s relative, the answer could be different for another developer, but the most important for me is now my developers are happier to use struts.

Task (computing) Event

Published at DZone with permission of Ronald Daniel, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • How To Design Reliable IIoT Architecture
  • What Is Test Pyramid: Getting Started With Test Automation Pyramid
  • Chaining API Requests With API Gateway
  • Tomorrow’s Cloud Today: Unpacking the Future of Cloud Computing

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: