Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Cleaned up page outline, and removed tags which weren't working.

Excerpt
hiddentrue

Details how to add prompts which are displayed when a user is in an input field and otherwise hidden.

Panel
borderStylesolid
titleTable of contents
Table of Contents
minLevel2

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.

...