Antwerkz, Inc.
1Jul/11Off

Apache Wicket Cookbook

Posted by admin

Packt recently published Igor Vaynberg's "Apache Wicket Cookbook" and I was fortunate enough to receive a review copy.  I've been a Wicket user since long before it was Apache Wicket.  I've developed applications ranging in complexity from simple IRC bot log viewers to conference management suites.  Knowing Wicket reasonably well, I tend to not bother reading books on the subject as most of them are aimed at the beginner.  And those I find just a tad boring.

What caught my eye about this book in particular, though, was the "cookbook" approach to the writing.  This book does assume that you know at least the basics of Wicket.  It doesn't spend any time on trying to justify Wicket's design or approach.  What it does do is get you into your code quickly.  The examples cover clearly a number of very common use cases and starts to fill in the corners (to borrow a phrase from Tolkien).  What I appreciated most about this book is that there are so many things that we, as wicket users and developers, just do because that's How It's Done.  While he doesn't start you from zero, Igor takes some time to explain a few of the whys and wherefores:  the sometimes subtle implications of why things are done certain ways, the consequences and options of other approaches.

The tone of the book is light and easy.  Unlike a "from scratch" style book, this one really is just a reference book of sorts.  If you'd like to deepen your understanding of Wicket, you should certainly read this cover to cover.  However, if you're just struggling with a topic or two, the targeted approach of the writing lets you zoom in on your problem and get back out to your app with little fuss.  It's the kind of book that I think long time users will appreciate.  If you use wicket to any extent, it wouldn't hurt to have a copy of this handy.

To whet your appetite, Packt Publishing has made a chapter available.  Chapter 5, Displaying Data Using Data Table, can be freely downloaded directly from the publisher's site.  Looking at the table of contents, you can see the book covers quite few hot spots in the development of any application:

  • Chapter 1: Validating and Converting User Input
    • Introduction
    • Performing form-level custom validation
    • Creating a custom validator
    • Composing multiple validators into a single reusable validator
    • Converting string inputs to objects
  • Chapter 2: Getting Down and Dirty with Forms and Form Components
    • Introduction
    • Creating linked selectboxes
    • Composing multiple form components into a single reusable component
    • Preventing multiple form submits
    • Protecting against spam with a CAPTCHA
  • Chapter 3: Making Forms Presentable
    • Introduction
    • Changing form component CSS class on validation errors
    • Using FeedbackPanel to output form component specific messages
    • Streamlining form component presentation using behaviors
  • Chapter 4: Taking your Application Abroad
    • Introduction
    • Storing module resource strings in package properties
    • Retrieving a localized string
    • Feeding dynamic localized strings to components using StringResourceModel
    • Using wicket:message to output localized markup
    • Overriding localized resources on a case by case basis
  • Chapter 5: Displaying Data Using DataTable
    • Introduction
    • Sorting
    • Filtering
    • Making cells clickable
    • Making rows selectable with checkboxes
    • Exporting data to CSV
  • Chapter 6: Enhancing your UI with Tabs and Borders
    • Introduction
    • Creating tabs with dynamic titles
    • Making a tabbed panel play nice with forms
    • Creating a client-side JavaScript tabbed panel
    • Using borders to decorate components
    • Creating a collapsible border
  • Chapter 7: Deeper into Ajax
    • Introduction
    • Adding Ajax validation to individual form components
    • Blocking until an Ajax request is complete
    • Providing Ajax feedback automatically
  • Chapter 8: Visualizing Data with Charts
    • Introduction
    • Charting with Open Flash Chart
    • Feeding chart data using a SharedResource
    • Responding to clicks
  • Chapter 9: Building Dynamic and Rich UI
    • Introduction
    • Swapping components using a select box
    • Creating dynamic forms
    • Creating a dynamic portal layout
  • Chapter 10: Securing your Application
    • Introduction
    • Creating a login page and forcing the user to log in
    • Authenticating with OpenID
    • Securing components using
    • IAuthorizationStrategy
    • Securing URLs and protecting against cross-site request forgery
    • Switching from HTTP to HTTPS and back again
  • Chapter 11: Integrating Wicket with Middleware
    • Introduction
    • Integrating with Spring
    • Integrating with CDI
    • Populating repeaters from a JPA query
    • Creating a model for a JPA entity

All told this is a great book and a great addition to your library.  This is easily something I'll keep coming back to while building wicket apps.

 

Technorati Tags:

Tagged as: Comments Off
3Mar/10Off

Wicket and Embedded GlassFish

Posted by admin

One of the newer features available in GlassFish v3 is the ability to run glassfish in an embedded mode similar to how jetty is often used. This is approach is very common when working with Wicket and is, in fact, part of the quickstart maven archetype.  So what I'd like to see is GlassFish in place of Jetty.  It's not terribly difficult once you get past the first few steps.  This is a pretty new (and evolving) option so the documentation isn't all that easy to find, necessarily, but it's building.  I'll list some resources at the end.

The first step, of course, is to configure maven appropriately.  In my pom.xml, I have the following:

    <repositories>
        <repository>
            <id>glassfish-repository</id>
            <name>GlassFish Nexus Repository</name>
            <url>http://maven.glassfish.org/content/groups/glassfish</url>
        </repository>
    </repositories>

This will add the repository to find the deployed GlassFish artifacts. With that done, we can define a few dependencies:

        <dependency>
            <groupId>org.glassfish.common</groupId>
            <artifactId>glassfish-api</artifactId>
            <version>${glassfish.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.extras</groupId>
            <artifactId>glassfish-embedded-web</artifactId>
            <version>${glassfish.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.web</groupId>
            <artifactId>web-embed-impl</artifactId>
            <version>${glassfish.version}</version>
            <scope>provided</scope>
        </dependency>

${glassfish.version} here is defined elsewhere in the pom to 3.0. The class at the center of it all looks like this:

public class Embedded {
    public void start() throws IOException {
        final Server server = new Server.Builder("testBuilder").build();
        ContainerBuilder containerBuilder = server.createConfig(ContainerBuilder.Type.web);
        server.addContainer(containerBuilder);
        final EmbeddedWebContainer container = (EmbeddedWebContainer) containerBuilder.create(server);
        container.setLogLevel(Level.INFO);
        server.createPort(8888);
        final EmbeddedDeployer deployer = server.getDeployer();
        DeployCommandParameters deployParams = new DeployCommandParameters();
        deployParams.contextroot = "/";     // overrides whatever the WAR contains
        File archive = new File("target/wicket-glassfish").getAbsoluteFile();
        System.out.println("Deployed: " + deployer.deploy(archive, deployParams));
    }
 
    public static void main(String[] args) throws Exception {
        new Embedded().start();
        while (true) {
            Thread.sleep(1000);
        }
    }
}

Now, that's all rather dense, I know. This code is a condensed version of a much larger, more complete version written by Alexis Moussine-Pouchkine. His blog is a great resource not only for embedded GlassFish but all sorts of GlassFish related topics. This is all that's needed to run your app on GlassFish.

There are a number of other avenues left to explore. If you want to run glassfish from maven, you'll want to probably look at this entry. You can also enable some security as noted here. For the definitive word on the matter, however, please see the formal documentation for embedded glassfish here.

4Mar/08Off

Groovy on the web the right way?

Posted by admin

I've recently started (re)exploring the world of Groovy and, thus, Grails. The idea of Groovy makes me pretty happy, but Grails kinda makes me cry for a number of reasons. The entire system is, as you probably know, basically RoR but with Groovy complete with scaffolding. The issues with scaffolding are well documented. Most of the scaffolding gets thrown away once you start doing anything "real" and Grails can certainly suffer from that. You can, of course, write your own templates and these templates are basically JSPs implemented with a Groovy flavor. This is where my disappointment really starts to build. JSPs, at least in my circles, are all but deprecated. Even JSF2 is moving away from a JSP-centric view and moving on to JSFTemplating. So why did the Grails guys decide to reimplement JSP?

But there's light at the end of the tunnel for me. There are two different projects that give me hope for using Groovy on the web tier: Gracelets and the Wicket Grails Plug-in. Both of these projects have two things going for them:

  1. They leverage existing frameworks and their component sets so we're not left reimplementing everything else as well.
  2. They use more component oriented approaches than JSP development tends to lead to.

I like the dynamic nature of Groovy and the fact you don't need to restart jetty every time you change a class. Maybe these options will make Groovy more palatable on the web. For me at least.

Filed under: Groovy, Java, JSF, wicket 1 Comment
20Jan/08Off

Qwicket 1.0

Posted by admin

Qwicket 1.0 is finally here. Apart from being entirely too busy with work and sick children, I've been anxiously waiting along with everyone else for the 1.3 release to go final. This version features some streamlined build process improvements and a more interesting default UI. You'll likely end up building a new UI but at least there's enough there to work with while your design guys build something more customized. Part of the delay has come from some odd compiling and generation problems in my development environment but I appear to have ironed all those out. If you see something odd, please don't hesitate to let me know and I'll try to iron out any issues as quickly as possible.

This release isn't entirely revolutionary but I hope to make some dramatic improvements over the next few months making Qwicket much more robust and to make it easier to base projects off of and track the changes as Qwicket evolves. I'd also like to add maven support and move to ant task and maven archetype based generation as that's a little lighter weight for something that (at least for the moment) you use to generate your project and then move on from.

Hopefully Qwicket will help you explore Wicket and get your projects running more quickly. If you have any requests, please feel free to file an RFE in the tracker.

Filed under: Java, qwicket, wicket Comments Off
10Aug/06Off

Denver JUG Recap

Posted by admin

Well, after months of trying to schedule and the last few frantic days of finishing up the slides, the Wicket presention is finally done. Overall, I'm pleased with how it went. There were no technical glitches to contend with which is always a concern going in to things like that. Once I finished writing the slides and going through the presentation it hit me how much info I was packing into it. Given that I only had an hour, next time I would change a few things about it. I'd drop a few of the slides so I could get to more code. There are slides with code on them but I think it's easier to understand in context. So I went longer in the slides than I wanted and didn't get to the code I was hoping to show.

The presentation itself went swimmingly as far as that goes, but I really wanted to show some code. Maybe next time, though. I'm putting a PDF of the slides up for those interested in seeing them again. Check the main page or click here to download them.

The Echo2 presentation was fascinating. I'm going to have to play with that one but it looks pretty nice from where I'm sitting. I'm not sure it'll replace wicket (or struts or JSF) in my toolbox, but for certain types of applications it certainly looks appealing. We also had a special guest with us. There was a very nice lady visiting us from Microsoft who was, of course, pitching MS products over beer. So we call had a few chuckles over that and had some beers together. It was strange at first to hear that a MS was at a JUG but she's really friendly and bought the first round of beers so it's all good. Overall, it was a great night. If you missed this month's meeting, you really missed out.

Filed under: General, Java, wicket Comments Off
9Jul/06Off

Introducing Qwicket

Posted by admin

I love wicket but like most frameworks, starting a new project can be a real hassle. You're either left to recode everything from scratch or, if you can, copying over an existing project and removing the vestiges of the old project and updating to the new one. This sort of works but tends to be tedious and error prone. So, taking a page from appfuse, I decided to create a quickstart application for wicket. Qwicket is a swing-based generator that will create the basic skeleton of a wicket+spring+hibernate application so you can get straight to application development. The code generated is based on what I've learned from the last few projects I've done in wicket. The generated code will continue to evolve as I receive feed back and fine tune the generation based on experience.

The decision to use a swing based generator is very intentional. I could've gone the ant route like appfuse did but if you've looked at the gymnastics that ant requires in appfuse, you'll begin to understand why I chose to go this route. Right now, there aren't really many options to set. Eventually what I plan on having is choices for using ibatis rather than hibernate, for example. I'd also like to have a basic bean builder and CRUD pages generator. Once features like this come on line, the Swing GUI makes more sense. Also, I'd really like to have this run via webstart eventually so you don't need to check out a svn repository to run it.

As wicket and qwicket continue to evolve, hopefully it will be very easy to track those changes. I've also debated adding support for qwicket to be able to edit an existing qwicket-based project but I'm afraid that's going down a road I'd rather not travel. For now, I hope this project can help beginners and experienced wicket users alike in the wicket development.

Filed under: Java, qwicket, wicket Comments Off