make a patch for this and add this to the bug/rfe/patch list on sourceforge.


On 9/20/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Hello,

many thanks to the developers of Wicket for their great framework.

I'm working on a major commercial project that will base its UI on Wicket. Hopefully our experiences will enable us to contribute something.

Starting with the Wicket examples, I had some problems to understand how the letter images are working in the hangman example:

  <a wicket:id="letter" href=""
    <img type="image" wicket:id="enabled"/>
    <img type="image" wicket:id="disabled"/>
  </a>

Why two images in the template?

More importantly why is only one of both showing up in the browser?

The answer can be found in Link#internalOnBeginRequest(), where children of a Link are hidden/shown according to their id.
The incorrect comment at the beginning ("Disabled" isn't appended) indicates to me that this behaviour isn't completely worked out:

  // Get disabled component of the same name with "Disabled" appended
  final Component disabledComponent = (Component)get("disabled");
  if (disabledComponent != null)
  {
    // Get enabled container
    final Component enabledComponent = (Component)get("enabled");
    // Set visibility of enabled and disabled children
    enabledComponent.setVisible (enabled);
    disabledComponent.setVisible(!enabled);
  }

What happens if there isn't an "enabled" component? IMHO an id of a component shouldn't have this side effect - it should not have any meaning at all. (Perhaps I've missed something, are there other places in Wicket where ids are interpreted?)

I don't know who is already using this 'feature', but for the hangman example I'd prefer another solution anyway:

Only one image in Guess.html (as a web designer would expect it):
  <a wicket:id="letter" href="">    <img type="image" wicket:id="image"/>
  </a>

Only one image in Guess.java:
  link.add(new Image("image", letter.getSharedImageResource()));

Finally a small change to Letter.java:
/**
* Get a resource for the image based on already being guessed.
*
* @return ResourceReference token for this letter
*/
public ResourceReference getSharedImageResource()
{
  return new ResourceReference(Letter.class, asString() + (isGuessed ? "_disabled" : "_enabled"))
  {
    private final boolean disabled = isGuessed;

    protected Resource newResource()
    {
      // Lazy loading of shared resource
      final DefaultButtonImageResource buttonResource = new DefaultButtonImageResource(30, 30, asString());
      if (disabled)
      {
        buttonResource.setColor(Color.GRAY);
      }
      return buttonResource;
    }
  };
}

What do you think?
- IMHO the solution above simplifies handling of enabled/disabled images in the hangman example.
- As I read other posts (e.g. PageLink's autoEnable) I think that there might be too much 'magic' going on in Wicket that confuses users. Perhaps the behaviour in Link#internalOnBeginRequest() should be removed or at least not be used in the default case.

Regards

Sven


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to