Matt RaibleMatt Raible is a writer with a passion for software. 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.
You searched this site for "struts". 749 entries found.

You can also try this same search on Google.

Display Tag: Static Headers - Revisited

I get a fair amount of hits on this site for my Display Tag: Static Headers post. When I originally wrote it, back in August, it didn't work in IE. So I asked the experts. I got a solution from that - split the tables and wrap the data table with a div that has style="height: 400px; overflow: auto". This works in IE, but since it's not easy to hack the HTML that the displaytag generates, this is an awkward solution.

Since my old demo disappeared when I updated struts-resume, I created a new one. This example shows how to do static headers in both IE and Mozilla - and the IE solution actually works in both. It's admittedly ugly, but it works. The major problem with this approach is getting the width of the top (header) cells to match up with the bottom (data) cells. I got them close using "th, td { width: 25%}" in my stylesheet, but that doesn't line them up exactly. If anyone knows of a better solution, let me know and I'll update the demo.

Posted in Java at Dec 04 2003, 01:51:05 PM MST 4 Comments

Struts Menu 2.0 Released!

This release is a significant refactoring of the 1.x codebase. The source and site is now built using Maven. Menus can now be defined using Velocity templates and support has been added for looking up dynamic values. This means that if you have ${variableName} in your menu-config.xml (in a link), the tag library will look in all scopes for a variable with the name "variableName". The example app has been updated to improve documentation.

IMO, the Velocity templates is huge because it means "if it's possible with HTML" - it's possible with Struts Menu.

Changes (from http://struts-menu.sourceforge.net/changes-report.html):

- Renamed package structure to net.sf.navigator.
- Added support for using Struts' actions and forwards for links in menu-config.xml.
- Added support for using dynamic variables in menu-config.xml.
- Updated build process to use Maven for building/deploying.
- Refactored to use Velocity and allow dynamic variable substitution.

You can read the nitty-gritty details about the Velocity enhancements, check out the sample app or download this tag library for yourself.

Posted in Java at Dec 01 2003, 04:03:09 AM MST Add a Comment

AppFuse 1.0 Released!

I feel this release deserves the big 1.0 designation because it is an up-to-date representation of my learnings and my perceived best practices in building web applications. Of course, as I learn more, I will continue to push out new releases.

In this release, I did a lot of refactoring and enhancements to existing features. The DAO and Manager interfaces are no longer tied to Struts or Hibernate. Hibernate's Session object is now passed as an argument into Manager and DAO constructors, rather than method signatures. The DAOFactory was refactored by Bear Giles to use reflection to instantiate Hibernate DAO's. Now, if you add a new DAO, you don't have to edit DAOFactory and DAOFactoryHibernate. To insantiate a new DAO, the code is now:

LookupDAO dao = (LookupDAO) DAOFactory.getInstance(conn, LookupDAO.class);

...where conn is a connection object retrieved from ServiceLocator or ActionFilter. When you add new POJOs, you still have to add them to ServiceLocator (for JUnit tests) and hibernate.cfg.xml, which is kindof a pain. I'd like to figure out a way to tell Hibernate to just look in appfuse-ejb.jar.

<tangent>
I still don't have a Factory for Managers, and I don't know that there's a need for one, but it's something I might add in the future. Managers are still creating using: LookupManager mgr = new LookupManagerImpl(ActionFilter.getConnection());. One thing I've been thinking about is the ability to switch webapp frameworks - kindof like you can do with Persistence Frameworks and the DAO Pattern. It'd be cool to add a way to switch (at build time) to use WebWork or Tapestry. Maybe by replacing values for the controller in web.xml. It'd probably be a pain since I'd probably have to create new JSPs for the new frameworks - but it would probably be a great learning experience.
</tangent>

The Remember Me feature has been refactored so the username and password cookies are only available under the /appfuse/security url-pattern. I also changed the posting to "j_security_check" in LoginServlet from response.sendRedirect to an HTTP POST, using Jakarta Common's HttpClient. The reason I have a LoginServlet vs. just using action="j_security_check" in my <form> is to encrypt passwords.

I've developed 3 different applications using AppFuse (struts-resume is one of them), and I have found that it's a pain to upgrade to new versions of AppFuse. Because of this, I don't recommend upgrading unless you really need to. I will be upgrading struts-resume to AppFuse 1.0, but I doubt I'll upgrade it to any future AppFuse releases - it's just too much work for not much reward.

Posted in Java at Nov 30 2003, 06:35:24 PM MST Add a Comment

JSTL Tips o' the Day

Here's a couple of tips to help you in your JSP development with JSTL:

  • The <c:out> tag has a default attribute you can use to provide a default value when the value in your the variable you're trying to write is null. This is much easier than using if statements. Example: <c:out value="${user.firstName}" default="None Given" />.
  • You can populate dynamic values in a key from your ResourceBundle using the <fmt:param> tag. For instance, if you have a message with a link in ApplicationResources.properties - and you want to populate it with a struts-forward, it's easy with JSTL:

    ApplicationResources.properties:

    mainMenu.link=Click <a href="{0}">here</a> to return to the Main Menu.
    
    In your JSP:

    <fmt:message key="mainMenu.link">
      <fmt:param><html:rewrite forward="mainMenu"/></fmt:param>
    </fmt:message>
    

Usually I try not to put any HTML in ApplicationResources.properties, but I don't think a minimal amount hurts anything. Of course, you could put all the HTML in your JSP, so mainMenu.link changes to "Click {0} to return to the Main Menu." and your JSP changes to:

<fmt:message key="mainMenu.link">
  <fmt:param>
      <html:link forward="mainMenu">here</html:link>
  </fmt:param>
</fmt:message>

Enjoy!

Posted in Java at Nov 30 2003, 06:14:20 PM MST 1 Comment

My Favorite Eclipse Plugins (Download v1.0)

When I go to new clients, I either have to install Eclipse, or help others configure Eclipse with cool plugins. So I made my own download of my favorite Eclipse plugins. If you want it, download version 1.0 from SourceForge. It includes the following:

Installation: Unzip to where ever you have Eclipse installed. I use c:\Tools\eclipse on Windows.

I don't really use XMLBuddy because it doesn't allow spaces (only tabs), but I suppose it's better than nothing. The built-in Ant Editor has the same behavior (tabs only). I'd love to find a plugin that gives code-completion for XDoclet when typing JavaDocs, but I couldn't find one. Sure, there's JBoss-IDE (which is just a bunch of Eclipse plugins), but that only has jboss-specific tags - no @hibernate, no @struts.

NOTE: Many of these plugins didn't work on Eclipse 3.0 M5, so I reverted back to M4.

OS X Users: Jalopy and Colorer don't seem to work at all for me (M4). You'll need to change Easy Explorer from "explorer.exe {0}" to "open {0}" in Window > Preferences > Easy Explorer.

These are all the latest versions as of November 26, 2003.

Posted in Java at Nov 26 2003, 01:02:59 PM MST 13 Comments

RE: Compressing and Caching in your webapps

Jayson Falkner writes about two Filters everyone should have in their webapps: one for compression (via gzip) and one for caching. I try to add a CompressionFilter to all the apps I write, but I don't have a CacheFilter. So my question is: should I add Jayson's CacheFilter to AppFuse or should I use OSCache? I haven't got to Dave's chapter yet on performance and caching (in JSP 2.0), so I haven't read his opinion - what's your opinion? I like Jayson's solution because I can add 3 new classses with no additional JARs - AppFuse already has 21 jars (Struts, Hibernate, JSTL + a few other taglibs).

Posted in Java at Nov 21 2003, 11:57:41 AM MST 4 Comments

Setting up my Fedora box with Out-of-the-Box

Rather than spending hours trying to recover my Red Hat 9 disk, I built a new disk/box with Fedora. For all I know, the RH 9 one is still recoverable, but I'm an upgrade junkie so I couldn't help myself. Setting up DHCP with Dynamic DNS was a bit of a pain, even when I followed this howto. I believe I ended up re-installing bind and everything worked (this was a 2 a.m. last night, so my memory is a big foggy).

The only thing I haven't been able to get running (so far) is my USB Printer, details on hpoj mailing list. It was easy to setup my OfficeJet G85 on RH 9.

As for setting up my dev environment, it was a breeze using Out-of-the-Box. However, out of the box the installer didn't work. I had to install "gd-devel" (a dependency of viewcvs) and then everything installed just fine. Hat tip to Eric Weidner (of EJB Solutions) for the tip. I was able to select the applications I wanted and get all of the following installed and running: MySQL, PostgreSQL, Apache, Tomcat, mod_jk2 (to connect apache and tomcat), Roller, Scarab, CVS, Java, Ant and ViewCVS. I'm sure I installed more, but these are the mains ones I was looking for.

While the installer for OBox takes a while to run (on 1.5 GB RAM with 1.5 GHz = 30 minutes), the beauty of OBox is that it configures everything for you and starts all the services. The one thing that is disappointing (or maybe it's good) is that it didn't setup any environment variables - no $CATALINA_HOME, $ANT_HOME, etc. No biggie, I can set those up myself.

I might just have to burn a CD of OBox for future clients. It'd be nice to show up with my development environment on CD and ready to go. One bug I did find was that the mod_jk2 install configures mappings for all the struts example apps (which I didn't install).

Posted in Java at Nov 21 2003, 12:55:55 AM MST Add a Comment

Wanted: View Source with syntax highlighting

The Display Tag has a nice feature in it's documentation: the ability to view the source of a JSP [example]. This is done using a servlet, and works fairly well. However, as I write documentation for Struts Menu, I'm finding I need to view more than just the source of JSPs, but also the source of stylesheets, scripts and Velocity templates. So far, I've found that the view source protocol works fairly well for this.

Nice Tabs Menu Examples: generated HTML, its JavaScript file, its CSS file

Normally, I would be perfectly happy with this - except the view-source protocol doesn't seem to work in Safari (last time I checked). Secondly, I got to thinking - it sure would be nice to have a Servlet (or some other technology) that would read in a file and spit out it's contents with syntax highlighting. This is to say that you'd see in your browser what you see in your editor (i.e. BBEdit, HomeSite, Eclipse, etc.).

The ideal tool would allow me to pass in a URL to a file, and it would spit out an HTML version of that file, complete with syntax highlighting. It'd be similar to Java2HTML, but it would allow HTML, JavaScript, Java, CSS and JSP. I noticed that it might be possible to generate HTML from Java using Java2HTML on the fly, but that only covers one file type. Another option is to instruct documentation readers to change their view-source editor to be their favorite editor.

Has anyone seen such a tool? It sure would be sweet for writing better and more readable documentation for web developers.

Posted in Java at Nov 19 2003, 08:51:19 AM MST 6 Comments

My New Project: Tasks and Dev Server Setup

My new project is going well so far. It's nice to bill for the commute and work from home twice a week. I'll be finished with the prototype for our first project today, and we'll start pair-programming on Thursday to implement it. Since one of my main objectives is to teach my supervisor everything I know, I think the best way to do this is to pair-program. I tried giving a couple of presentations on Hibernate and XDoclet, but my supervisor is a Java Greenhorn, so even that was a little advanced.

Our first project is to automate job posting to the various job posting boards the client subscribes to. Currently, a person in HR enters the job onto their website, and then visits each job site (or sends an e-mail) and manually enters the information. The application we're developing will allow them to enter the job on their website, select which boards they want to post to, and submit the form. I initially received a list of 32 websites and newspapers. After contacting them all, I'm amazed the archaic systems that are in place for this "automation." Most sites will accept a simple e-mail in whatever format we want. In my mind, this means a person is going to manually read the job posting and manually enter it into their system. Great, it's easy enough for me to compose an e-mail. 2 out of 32 allow for FTPing text files in a certain format, and 1 site has an XML format (not DTD, just a format) that they expect to be attached to an e-mail. This is a *huge* opportunity for webservices and a common XML Schema (if you ask me).

The one thing that's been slightly frustrating is getting a development environment setup. I (as usual) need to setup CVS, a bug tracking system, automated tests, etc. It's a Windows shop, so no Linux allowed. Not a big deal, but I haven't been able to get VPN access yet. No VPN means that I can't checkin stuff from home - which is dangerous IMO. My supervisor suggested we setup everything on my Linux box at home, which is fine with me, but could be a lot of maintenance on my part (permissions, UPS, backups). For bug tracking, I'm leaning towards Bugzilla over Scarab because I'm familiar with it. I'd like to use JIRA, but don't want to shell out $800 to impress a client with some nifty bug tracking software. Free is always easier to sell to clients. I've actually thought about buying a JIRA license for Raible Designs and hosting my clients bugs (while I'm on the project), but it might be a pain to transition once I leave (I suppose I could rent the space to them or something). So what I'm asking for is - if you had to administer your own Linux box for your day job - how would you do it? Groups? Backups? UPS? If I don't do it on this project, I'll probably do it someday.

Posted in General at Nov 18 2003, 12:53:20 PM MST 3 Comments

Yet Another Web Application Framework: Shocks

From watching the struts-dev mailing list, I discovered a new Servlet Framework called Shocks. The thing that interests me about this framework is that the author looked extensively at Struts and WebWork both before creating it. It's feature-set sounds nice too:

It has an aspect-oriented workflow engine that can add crosscutting
system logic (like form processing, L10N, security, logging, etc) dynamically at
runtime (without having to mess around with the bytecode).  It can trade actions
across classloader boundaries, enabling web applications to span across multiple
.WAR files.  This allows users to drop in a new .WAR with new metadata and new
actions, which updates the application workflow at runtime across all modules in
the application namespace.  It handles workflow versioning and version rollback
(in case you make changes you come to regret).  It does instance pooling of all
components and sequences.  Every aspect of the system can be managed with JMX at
runtime.

Sounds like Spring, eh? Yes, says the author.

I think there are appreciable differences that have yet to be realized between 
the two (I haven't read their code at all), but definitely a lot of conceptual 
crossover.

I would think that introducing a new framework into the mix (and convincing folks to use it) must be pretty tough at this point, unless you create an IDE to go with it or introduce it in a book. BTW, did you know you can use Tiles with Spring.

Posted in Java at Nov 18 2003, 05:28:45 AM MST 2 Comments