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="/Wicket-Examples/sandbox?path=0:form&interface=IFormSubmitListener"
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