what version of wicket are you using?
Can you use the cvs/head version or wait for the final RC which should be out there pretty soon.
Buttons shouldn't empty there value anymore.

On 10/5/05, Eduardo Rocha <[EMAIL PROTECTED]> wrote:
This problem can be seen clearly in compref example. If you see the "live action" from wicket web site, the Button component reference is just fine, but if you download wicket and wicket-examples b4, you see the same page with buttons without label, and then the buttons also doesn't work as expected (since the missing labels - value attribute - are used to see which button was pressed).

2005/10/5, [EMAIL PROTECTED] < [EMAIL PROTECTED]>:
Hello,

I'm having a problem with model-less forms:

  public FormWithoutModel()
  {
    Form form = new Form("form");
    add(form);

    Button button = new Button("submit");
    form.add(button);
  }

  <form wicket:id="form">
    <input type="submit" wicket:id="submit" value="Process Order"/>
  </form>

Although the button tag has a value attribute, Wicket insists on rendering it empty:

  <form action="" method="post">
    <input value="" type="submit" name="submit"/>
  </form>

The reason for this unexpected behaviour can be found at the end of Component#getModelObjectAsString():

  public final String getModelObjectAsString()
  {
    final IModel model = getModel();
    if (model != null)
    {
      ...
    }
    return "";
  }

If no model can be found, an empty String is returned.

Now locking at Button#onComponentTag(ComponentTag):

  String value = getValue();
  if(value != null)
  {
    tag.put("value", value);
  }

... we'll see that each non-null value will override the value attribute from the HTML template.

I wouldn't expect this behaviour. If others too think that this should be improved, I'd suggest the following:

a) Either let getModelObjectAsString() return null if no model is found (this could have a major impact on others components)

b) or let Button override the value attribute from the HTML template only if the value is non-null *and* non-empty.

Thanks

Sven


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user


Reply via email to