You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Table of contents

Scenario

Sometimes, it is useful for text to be displayed when a user is in a form element, and hidden when they leave the field. An example would be a prompt which offers help about the expected field contents, but which generally doesn't need to be displayed, since displaying them all at once would clutter up the interface.

This article will cover how to achieve this in your wicket page.

Overview of Options

Three basic ways to achieve this functionality are:

1. Create ajax behavior which gets fired when field is entered/left.

  • Pro: Most dynamic solution.
  • Con: Requires multiple round trips to server per user.

2. Tag each field with an hint attribute, and use javascript tools to display the text as needed.

  • Pro: Works as needed.
  • Con: Performed at the page level, needs components to be tweaked to match.

3. Wrap #2 inside of appropriate wicket components/behaviors.

  • Pro: Achieves goal, and works within components.
  • Con: Additional work needed over #2 for initial implementation.

Implementations

1. Create ajax behavior which gets fired when field is entered/left.

I could not determine how to work through the first option. I leave this for someone else.

2. Tag each field with an hint attribute, and use javascript tools to display the text as needed.

I will shortly be detailing how to achieve this, using the mootools library.

3. Wrap Implementation #2 inside of appropriate wicket components/behaviors.

Help needed to flesh this out correctly.

  • No labels