This week I ran into a problem, where a button suddenly changed its inscription which was supposed to be specified in the HTML template.

Reason for this was that we added a new property to one of our model objects. We're using CompoundPropertyModels (who doesn't?) and the value of the property was rendered because as chance would have it the button has an identical wicket:id :(.

I found the origin of this unexpected behavior in Button#onComponentTag(ComponentTag) :

   try
   {
       String value = getModelObjectAsString();
       if (value != null && !"".equals(value))
       {
           tag.put("value", value);
       }
   }
   catch (Exception e)
   {
       // ignore.
   }

IMHO this code is problematic in either way:
- if the value attribute should stay untouched as specified in the HTML, you carefully have to watch out for collision of property name and wicket:id - if the value attribute should be generated, you won't get an error if the property is misspelt.

I propose to formalize the behaviour of Button with a new method, say:

   Button#setOutputMarkupValue(boolean)

If you wonder, the name of this method was inspired by Component#setOutputMarkupId().

What do you think?

Sven



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to