| Subcribe via RSS or via Email

Expanded Wicket Component Expressions

November 22nd, 2009 | No Comments | Posted in Java, Wicket

I have updated my wicket component expressions library to include enabled and visible conditions in the expressions.

This basically means that you can filter your component expression by if a component is visible, enabled, or both. The following is an example of what can now be done:

"one1[enabled=true]:two1[enabled=true]"
"one1[visible=true and enabled = true]:
                 two1[visible=true & enabled=true]"
"**[visible=true]"

As before the code is available on the london wicket google code project, under an apache 2 licence. Due to the additional functionality I have bumped up the version number to 0.2.0, so you will need to update you pom to reflect this.

Tags: ,

Wicket Component Expressions

November 8th, 2009 | 3 Comments | Posted in Java, Wicket

While writing some unit tests for a wicket application I was working on, I found that I was writing a lot of component path expressions to get at various components in my pages.
However after some refactoring of the page hierarchy I had to re-write most of the expressions to take make the tests work again.

This lead me to think that maybe there could be an easier way for getting at components, using * to represent any child component at a given level, and ** to represent any child component at any level.

Doing this would mean that you could re-write this:

“panel1:innerpanel1:form1:textfield1”

as

“*:*:form1:textfield1”

or

“**:form:textfield1”

or even

“**:textfield1”

Then I got thinking that I would be pretty simple to place type restrictions on the results, so you could set the following expression:

“**” and type restriction of TextField

to get all TextField component on the page or

“panel1:**” and type restriction of ListView

to get all ListView components which are children of the panel1 component.

To use component expressions I created 4 static methods

  • public static Component findComponent(Component parent,
     String expression)
  • public static Component findComponent(Component parent,
     String expression,Class<? extends Component>typeRestriction)
  • public static List findAllComponents(Component parent,
     String expression)
  • public static List findAllComponents(Component parent,
     String expression, Class<? extends Component> typeRestriction)

The code is checked into the london wicket google code repository, and you can include it as a dependency to your project by adding the following to your pom.xml

<repositories>
	<repository>
		<id>londonwicket</id>
		<url>http://londonwicket.googlecode.com/svn/repo</url>
		<releases>
			<enabled>true</enabled>
		</releases>
		<snapshots>
			<enabled>true</enabled>
		</snapshots>
	</repository>
</repositories>

<dependency>
	<groupId>com.googlecode.londonwicket</groupId>
	<artifactId>wicket-component-expressions</artifactId>
	<version>0.1.0</version>
</dependency>

There are tests to cover all the different cases I could think of. Any comments, bug fixes, or improvements would be more than welcome.

Tags: ,

Updated terrcotta wicket-tim

December 7th, 2008 | 7 Comments | Posted in Java, Wicket

The latest version of the wicket 1.3 and terracotta integration is out (1.1.3).

The code will now automatically configure your application to use the correct page store, with a default of 100 pages history per page map.  If you need to override this value then you can override the the newSessionStore method in your WebApplication class, as in the previous version (see this post).

So in most cases all you need to do to use wicket with terracotta is include the tim in your terracotta configuration like so.

<module name="tim-wicket-1.3" version="1.1.3"/>

The next thing i’m going to be working on is wicket 1.4 support, which I should get finished before wicket 1.4 goes live.

Tags: ,