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 "form". 326 entries found.

You can also try this same search on Google.

Cactus and Form-Based Authentication

Quick Summary: Did you know it's possible to login (with form-based authentication) before running each of your testXX methods in a ServletTestCase or CactusStrutsTestCase? Just add a "begin" method in your Base class, or in each of your Tests, and it will be called automatically, just like setUp() is called.

    public void begin(WebRequest request) {
        request.setRedirectorName("ServletRedirectorSecure");
        request.setAuthentication(new FormAuthentication("tomcat","tomcat"));
    }

Long and Winded: Yesterday, I began adding the "roles" attribute to my Struts action-mappings - to limit access for certain user roles (Yes, XDoclet 1.2 supports this). This worked great in my web UI, until I tried to run my StrutsTestCases. Access was denied because I was not logged in. Rather, I was "faking it" by retrieving a UserForm object in my setUp() method and stuffing it into the session [View Source]. This worked like a charm until I added the roles restriction.

Cactus has a nice feature: if you write a beginXX method, it will be called before your testXX method. In other words, begin = client, test = server. So I added a number of beginEdit, beginSave, etc. method to my Action Tests. Great - everything worked. But it was ugly to add all those beginXX methods. Then, via Vincent Massol's wisdom, I learned of the global begin(WebRequest wr) method. Now I simply have a begin() method in my BaseStrutsTestCase class, and everything works as smooth as pie.

    public void begin(WebRequest request) {
        request.setRedirectorName("ServletRedirectorSecure");
        request.setAuthentication(new FormAuthentication("tomcat","tomcat"));
    }

A couple of issues I discovered:

  • If you have an Action that doesn't have any roles in any of it's mappings, this will fail, so you have to override the begin() method with an empty {} method in your *Test.class. I believe the error message was it couldn't find the SecureServletRedirector.
  • You must define all the roles (you plan to authenticate with) in your Ant build.xml file. [Read More]
  • My <error-code>403<error-code> is not working on AppFuse or the current real-world app I'm working on. [Read More]

All in all, I'm pretty pumped that Cactus makes it this easy to test my app in its true production environment.

Later: I figured out the source of the 403 error-page not rendering. Once again, my Compression Filter does more harm than good. I switched it out for a more recent GZIPFilter and the same thing happens. The good news is that the new filter works on Resin, whereas the old one did not.

Posted in Java at Jan 08 2004, 01:46:32 PM MST Add a Comment

HowTo: Get an input field's value with Canoo's WebTest

I should start this by saying that I love Canoo's WebTest. It allows you to test clicking through your webapp as if you're using a browser. You simply write your tests in an XML file (which is really an Ant build file), and then run it with Ant. Usually, in my webapps, I write simple tests for CRUD on entities - i.e. EditUser (tests pulling up the edit screen), SavePosition (edit and save, verifies next screen's title), SearchUsers (verifies list screen's title).

One of the issues I had this morning was testing a wizard with WebTest. This was because I didn't know how to get the id of the new record after it was added. Now I found a way. Let's say you have a Create a Job wizard. On the first screen, you enter the job, and on the second, you add the required skills, on the third, you view a summary. To get the new id of the job, you can use XPath to get the hidden field named "jobId" - to do with what you may (i.e. click on a link to the third screen). Here's how: {{{ }}} This is especially helpful because I tend to use a lot of onclick handler's (with location.href's) on buttons (so I don't have to submit to the same action). I also turn off JavaScript for my tests - by not including js.jar in WebTest's classpath. I can't say enough about this tool - the ability to test your app, with JavaScript turned off, and verify that everything works... that's just cool. Especially when you're a JavaScript junkie like me.

Posted in Java at Jan 06 2004, 05:25:15 PM MST 5 Comments

Filtering Roller Feeds by Category

Simon posted today that Pebble supports RSS Feeds by Category. Just so you know, Roller also has this feature, - just add "?catname=categoryName" after /page/$username. Here's all my current categories.

This is a great feature to have in your blogging software. Without it, javablogs.com would be getting all my posts, rather than just my Java and Roller categories.

Posted in Roller at Dec 02 2003, 09:20:13 PM MST 4 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

My IDEA Evaluation - Eclipse is better

I've been trying to use IDEA (on OS X) for the past few weeks and I keep reverting back to Eclipse for features that seem to be missing. I know the features must be there, but I just can't find them. Why else would everyone like it so much? Sidenote: I've never used IDEA for a feature that doesn't exist in Eclipse - I'm sure there are some, I'm just not using them. It sure would be cool if someone created a HowTo explaining how to migrate from Eclipse to IDEA. In the meantime, I'll settle for posting my questions here:

  • Debugging in Tomcat - I'm currently using Sysdeo's Tomcat Plugin in Eclipse for Tomcat 4.1.27. It's super easy to setup and use - I expect the same ease-of-use from IDEA. I haven't looked much, but I'd love to hear feedback on IDEA's Tomcat debugging support.
  • Renaming a variable in a JavaBean renames getter and setter methods. Sounds simple enough, in my 10 second search, I couldn't find it. In Eclipse, right-click -> Refactor -> Rename.
  • Override/Implement methods (from parent classes and interfaces). Right click -> Source -> Override/Implement methods in Eclipse.

I'll add more as I think of them throughout the day. So far, I like IDEA, but to be honest - it's not saving me any time over Eclipse. It also locks up as much as Eclipse and it's responsiveness is still a big sluggish on OS X (10.2.8) with 1 GB of RAM (1.33 MHz processor). Hopefully Panther will make both IDEs faster. Two weeks ago, I was thinking of buying it (as well as Dreamweaver) - now I'm frustrated with IDEA's lack of features and Dreamweaver's slowness. I'll probably pass on shelling out the cash since Eclipse and BBEdit are giving me all the features I need in IDEA and Dreamweaver.

Posted in Java at Oct 20 2003, 06:17:51 AM MDT 22 Comments

Dynamic Queries with Hibernate

I have a client that wants the ability to search on all columns in all tables in their database. So far, I've been able to get all the columns, and their friendly labels by getting all the *Form.* keys in my ApplicationResources.properties file. I still need to sort them alphabetically, but that's another issue. Now I have the following UI pretty much done:

I'm happy with the UI, but I'm struggling with getting Hibernate to return my desired results. I'm able to dynamically select the table/column to search on because of values in my "tables/columns" drop-down. However, many of these tables have Id fields - for status fields, type fields, etc. (basically drop-downs). When searching, this is a pain because users are likely to search on "Active" rather than "1". Because of this, my first issue is how do I make the status field's friendly name a part of my POJO (with Hibernate)?

My 2nd issue is regarding Hibernate's Expression API. I want to be able to pass in the criteria (=, contains, <, >), propertyName and value and get my results. However, it seems that the second half of the comparison must be the same datatype as the field. This means if you're searching on "contract amount", and its a Double, I need to do a Double.valueOf(searchTerm). Basically, I'm looking for an easy way to do this:

  Criteria filter = ses.createCriteria(clazz); 
  
  // determine type of expression - I'd love to figure 
  // out a cleaner way to do this but there's only 
  // 5 possible types, so I don't mind typing the 5
  // if statements
  if (expression.equals("=")) { 
    // How do I convert these to the fields' type at run-time?
    // Sure I could do a bunch of if statements again, but it seems ugly.
    filter.add(Expression.eq(field, Double.valueOf(value))); 
  }
 
  List results = filter.list();

Any advice is appreciated - especially considering I estimated this task to take 4-5 hours and I'm going on 8.

Posted in Java at Oct 05 2003, 10:39:29 AM MDT 11 Comments

Struts tip o' the day ~ using bean:size

A co-worker turned me on to this one today - you can use <bean-el:size collection="${myForm.list}" id="listSize"/> to get the size of a collection and expose it as a pageContext variable. I've been looking for this sucker for years! Usually, I end up putting a getListSize() getter on my form to accomplish this, since none of the other tags (including JSTL) allow you to get the size of a collection.

Posted in Java at Sep 30 2003, 07:25:59 PM MDT 6 Comments

Why Intuit Sucks

Intuit, the maker of QuickBooks and Quicken, does not make good OS X software. Why? Because it can't read the Window's versions of its files. I bought Quicken so we could edit our Quicken files with our Macs, as we currently do with our PCs (data file is stored on Linux). To edit our Quicken files on the Mac, we have to export a QIF file from Quicken/Win and then import on Quicken/Mac. Good thing I wasted my money on a Windows version of Quicken and a Mac version - since I'll obviously only be able to use one.

Same goes for QuickBooks - if you want to edit your Windows-created QuickBooks file on a Mac, you must export/import. That just sucks! Intuit - have you ever heard of this company called Microsoft? They seemed to have no problems making their software read files created by either platform - maybe you should take a lesson from them.

Posted in Mac OS X at Sep 23 2003, 05:27:11 AM MDT 14 Comments

Test driving the new PowerBooks

I called my local Apple Store today to see if they had any new PowerBooks in. They did (though they've sold out of their 15" with combo/super drives for the day), and now I'm here test-driving the 17" with 1.33 Mhz and 512 MB RAM. It wouldn't be right if I didn't compare this machine against these performance numbers. So here goes:

  • Opening Eclipse (3.0 M2): 10 seconds
  • Opening Photoshop (7.0.1): 8 seconds
  • Running "ant rebuild" on Roller (0.9.7.3): 32 seconds (ooh, this actually beats the 2 GHz machine I had at Comcast, by 4 seconds).
  • Running "ant clean package-web" on AppFuse (0.9.1): 21 seconds (3 seconds slower than the 2 GHz Pentium)

I'm not as disappointed as I thought I'd be. Good thing I left my wallet in the car!

Posted in Mac OS X at Sep 18 2003, 06:17:43 PM MDT 2 Comments