Wicket enclosures and ajax : no no

Okay, this will be my second post in English, so, don’t go too hard on me :)

Earlier today, I was working on a web application using Wicket as framework, and I’ve got bitten by something that I wanted to share.

More precisely, it’s about enclosures and ajax : I had a link inside a list item and I wanted to bind the visibility of the latter to of the former.

So, I went ahead and enclosed the list item in an enclosure specifying the link wicket id as a value for the child attribute :

<wicket:enclosure child="generateReport">
	<li>
		<a href="#" wicket:id="generateReport">Generate report</a>
	</li>
</wicket:enclosure>

And this worked just fine, until I’ve decided I wanted to change the link’s visibility using Ajax.

So, when generating a full web page response, Wicket is perfectly able to handle the enclosures. But when ajax is involved, Wicket simply can’t handle them because they have no corresponding element in the html page, and thus they can’t be updated later. The inner element’s (<a> in this case) visibility will be affected but that’s not the case for the enclosure whose visibility remains static (depending on whether it was visible or not when the page was generated).

Note: The Wicket’s wiki mentions this behavior :

Note: Changing the visibility of a child component in Ajax callback method will not affect the entire enclosure but just the child component itself. This is because only the child component is added to the AjaxRequestTarget.

About these ads

2 Responses to Wicket enclosures and ajax : no no

  1. Hi!

    Now there is a fine automated solution for ajaxified enclosures:

    https://issues.apache.org/jira/browse/WICKET-3422

    • jawher says:

      Hi Martin,

      The patch provides a very elegant solution indeed, thanks for the link: I voted for it !

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: