Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

Simplify your AppFuse Managers

I figured out a way to remove any ActionForm references from my Managers yesterday. It was pretty simple, but I thought others might benefit from this knowledge. Basically, you just need to add a couple methods to your BaseManager.java file. Here is the latest one from CVS HEAD. Then you can pretty much eliminate any *Form references in your Manager by using the convert(Object) method. This method will convert POJOs <-> Forms and vise versa. You will likely have to do some tweaks on the package names if you're using anything < v1.4. Looking at this diff of the UserManager before and after this change will show you what's changed.

I started this task thinking I could remove the need for Forms in my classpath when compiling the service layer. However, I soon discovered that my Tests have Forms all over the place - since they replicate what my Actions will pass in. Oh well, at least my code is a bit cleaner now.

Of course, this code will become even simpler when I start using an MVC Framework that allows my POJOs to be my data handlers on the UI. These frameworks make me question if I even need Managers. Then again, it's nice to unit test what your DAOs are returning/receiving from the web layer.

Posted in Java at Feb 19 2004, 11:28:41 AM MST 2 Comments
Comments:

You are using Struts, why would you not be able to put your POJO's in your ActionForms? If there is a limitation, then I would think it would be due to Hibernate or the persistence layer of choice. I have never really understood the need for conversion when you can easily nest your POJO's into your ActionForms. Is it a package dependency that you are trying to avoid? Seperation of layers? I must be missing something, please elaborate.

Posted by Carl Fyffe on February 20, 2004 at 04:28 AM MST #

My reasons are simple - I generate my Forms from POJOs and all my properties are Strings. The main reason for this is so I can re-display values in the form elements when they don't validate properly. I could certainly nest my POJOs in my forms (and therefore have very simple forms). I used to do it this way and it felt ugly, but it certainly was easy. Here's an idea that I hope to bring to reality in the next year or so:

1. Override ActionServlet so that the execute method takes an Object instead of an ActionForm.
2. Allow POJOs to be used in Struts Actions and use the Validator and possibly AOP or Interceptors to validate POJOs.
3. Continue to use the Validator's client-side validation feature.
4. Figure out a way to accomplish the above, but still allow for displaying any invalid input in form elements.

If the Validator could validate POJOs as easily as it can ActionForms, it could be used in any MVC framework - powerful stuff!

Posted by Matt Raible on February 24, 2004 at 05:31 AM MST #

Post a Comment:
  • HTML Syntax: Allowed