jQuery in Action, 2nd edition*
The moose likes Struts and the fly likes Design Patterns and Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Design Patterns and Struts" Watch "Design Patterns and Struts" New topic
Author

Design Patterns and Struts

Andrew Leer
Ranch Hand

Joined: Nov 11, 2003
Posts: 44
Hi,

Just to get a better feel for it, are there any Design Patterns that are good to adhear to in Struts? From my 10 foot view it appears like Struts was badly designed with endless extentions of the DispatchAction and Action classes, (but what do I know...I guess that's why I'm asking...)

Also what do you call those things in the taglibs that go ${var.prop} as when I look in the documentation they don't really seem to be there. Are those things in the page scope?

Thank you,
Andrew Leer
Andrew Leer
Ranch Hand

Joined: Nov 11, 2003
Posts: 44
Okay so these things are called (${ }) EL (Expression Language).

Alright I can see that. But now I have another question. Why can't you access constants from EL? Yes, yes, I know there's an artical on it over at the Jounral this week. And the guy who wrote it is successful in thawrting that with the tag-lib he wrote. But...

There has to be a good reason/alternative to WHY it is that you can't access constants from EL.

So in summary these are my questions:

  • What if any design patterns should you utilize when programming in Struts and dealing with Actions?
  • Why is it that you cannot you access constants from EL (Expression Language)?

  • Merrill Higginson
    Ranch Hand

    Joined: Feb 15, 2005
    Posts: 4864
    What if any design patterns should you utilize when programming in Struts and dealing with Actions?

    One must never lose sight of the fact that a Struts application is a J2EE (I guess the correct term now is "Java EE") web application. It's got a few utilities and cool tricks, but it remains a J2EE application. As such, the entire list of J2EE patterns applies to a Struts application. Here is the URL to the J2EE Patterns developed by Sun Microsystems:

    http://java.sun.com/blueprints/corej2eepatterns/index.html

    The "Front Controller" pattern is already implemented for you by Struts, but all the others are good candidates for a you to use in your applications.

    Although Struts is indeed an MVC (Model/View/Controller) framework, the assets it provides really only cover the view and the controller. Building the model and accessing the model through the controller is up to you. To do this, you can definitely benefit from the patterns mentioned in the link above.

    Why is it that you cannot you access constants from EL (Expression Language)?


    That's the $10,000 question. Many of us wish EL had better support for constants, and are pushing for it in the next release. Without being able to speak for the developers of JSTL and EL, my guess is that the answer has to do with the fact that EL was developed to work exclusively with JavaBeans. It was not designed as a substitute for Java code, but a way to easily and conveniently access JavaBeans from within a JSP. Constants are not part of the JavaBean spec, and I suppose this is one reason they were left out. The reality is, most of us rely heavily on constants, and it's not at all convenient to have to jump through hoops in order to use them in EL.

    I hope you're clear on the fact that Struts and EL are entirely separate. EL and JSTL are part of the JSP spec, while Struts is a web framework built over the Servlet and JSP specs.


    Merrill
    Consultant, Sima Solutions
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Design Patterns and Struts