Forcing model update?

2009-05-06 Thread Thierry Leveque
Hi

Is there a way to force the model to update even if the field value is not
change?

Why would I want to do that?

Because I am using Castor (xml) object. And for element of type Int, the
Castor objects have a boolean method like HasElementName. It is set to
false until the value of the element is set. If HasElementName is set to
false and the element is mandatory (from the XSD definition), there will be
a validation exception when trying to marshall the xml.

The problem is with the default value (has defined in the XSD). If I have an
element with a default value like 5 for example. This value will be
displayed on my page correctly, but when I save it without changing the
value, the model object is not updated. Then the HasElementName is not
change and the exception is throwed!

Of course I have a workaround. Just before creating the component, I can add
something like: CastorObject.setElementValue( CastorObject.getElementValue()
); to force the value to be set using the current value.

But I think this is ugly...

Thierry


Re: Forcing model update?

2009-05-06 Thread James Carman
Call Component.modelChanged()?

On Wed, May 6, 2009 at 10:40 AM, Thierry Leveque tleve...@gmail.com wrote:
 Hi

 Is there a way to force the model to update even if the field value is not
 change?

 Why would I want to do that?

 Because I am using Castor (xml) object. And for element of type Int, the
 Castor objects have a boolean method like HasElementName. It is set to
 false until the value of the element is set. If HasElementName is set to
 false and the element is mandatory (from the XSD definition), there will be
 a validation exception when trying to marshall the xml.

 The problem is with the default value (has defined in the XSD). If I have an
 element with a default value like 5 for example. This value will be
 displayed on my page correctly, but when I save it without changing the
 value, the model object is not updated. Then the HasElementName is not
 change and the exception is throwed!

 Of course I have a workaround. Just before creating the component, I can add
 something like: CastorObject.setElementValue( CastorObject.getElementValue()
 ); to force the value to be set using the current value.

 But I think this is ugly...

 Thierry


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org