Re: [Wicket-user] Use getConverterInput rather than updateModel in FormComponentPanel
protected Object convertInput() { return dateField.convertInput(); } but that will mean that it will call twice convert intput on the inner date field. johan On 7/3/07, Eelco Hillenius <[EMAIL PROTECTED]> wrote: > by the way this is a bit more dangerous now: > > protected void convertInput() > { > setConvertedInput(dateField.getConvertedInput()); > } > > this goes ok because we visit child post order. and because dateField is a > child it works > But getConvertedInput and convertInput() are called in different flows. Yeah, I noticed that. I couldn't really think of a better solution though. Either you tell users to override a method that can (will) be called multiple times - getConvertedInput - and there isn't even a guarantee when that is, or, like we do now, we tell users to override a method that will only be called once and at a clear point in the processing. WDYT Johan? Eelco - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Use getConverterInput rather than updateModel in FormComponentPanel
> by the way this is a bit more dangerous now: > > protected void convertInput() > { > setConvertedInput(dateField.getConvertedInput()); > } > > this goes ok because we visit child post order. and because dateField is a > child it works > But getConvertedInput and convertInput() are called in different flows. Yeah, I noticed that. I couldn't really think of a better solution though. Either you tell users to override a method that can (will) be called multiple times - getConvertedInput - and there isn't even a guarantee when that is, or, like we do now, we tell users to override a method that will only be called once and at a clear point in the processing. WDYT Johan? Eelco - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Use getConverterInput rather than updateModel in FormComponentPanel
by the way this is a bit more dangerous now: protected void convertInput() { setConvertedInput(dateField.getConvertedInput()); } this goes ok because we visit child post order. and because dateField is a child it works But getConvertedInput and convertInput() are called in different flows. johan On 7/2/07, ChuckDeal <[EMAIL PROTECTED]> wrote: Eelco Hillenius wrote: > > Good point. I didn't think about getConvertedInput being called > multiple times. I'm working on a refactoring now. Removing final from > getConvertedInput wasn't the smartest thing to do it turns out. I'm > thinking about making that method final again, and instead removing > final from convert (and rename that to convertInput) and add > setConvertedInput. You can then override convertInput and call > setConvertedInput with the new value, and be sure this method will > only be called once. > As it turns out, using getConvertedInput was the best for me either :). When I was writing a validator for my component, the input was null which caused it to throw an exception. Upon figuring out why it was throwing the ex, I realized that I really wanted my Custom component to defer to the underlying text box, so I made getInputAsArray return the underlying TextBox's getInputAsArray and then I overrode convertValue to do what getConvertedInput was doing before. And since I now have valid data from getInputAsArray, validators don't cause exceptions. Chuck -- View this message in context: http://www.nabble.com/Use-getConverterInput-rather-than-updateModel-in-FormComponentPanel-tf3873952.html#a11399774 Sent from the Wicket - User mailing list archive at Nabble.com. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Use getConverterInput rather than updateModel in FormComponentPanel
Eelco Hillenius wrote: > > Good point. I didn't think about getConvertedInput being called > multiple times. I'm working on a refactoring now. Removing final from > getConvertedInput wasn't the smartest thing to do it turns out. I'm > thinking about making that method final again, and instead removing > final from convert (and rename that to convertInput) and add > setConvertedInput. You can then override convertInput and call > setConvertedInput with the new value, and be sure this method will > only be called once. > As it turns out, using getConvertedInput was the best for me either :). When I was writing a validator for my component, the input was null which caused it to throw an exception. Upon figuring out why it was throwing the ex, I realized that I really wanted my Custom component to defer to the underlying text box, so I made getInputAsArray return the underlying TextBox's getInputAsArray and then I overrode convertValue to do what getConvertedInput was doing before. And since I now have valid data from getInputAsArray, validators don't cause exceptions. Chuck -- View this message in context: http://www.nabble.com/Use-getConverterInput-rather-than-updateModel-in-FormComponentPanel-tf3873952.html#a11399774 Sent from the Wicket - User mailing list archive at Nabble.com. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Use getConverterInput rather than updateModel in FormComponentPanel
> I am making a ComboBox component that extends FormComponentPanel. I did as > you said, and I override getConvertedInput(), but the body of the method > scans a List to find a matching item. With only a few items, this isn't too > bad, but I'm afraid of performance problems as the list size grows. Also, > that method is already called twice and I am planning on writing a Validator > for it, which will cause it to be called at least three times per update > cycle. I was wondering if you could suggest a caching strategy for me to > try? I can store the converedInput on the Component, but what about > cleaning up that cached value? Will I need to worry about stale data being > returned by getConvertedInput? or will the Component's normal lifecycle > protect me from that? Good point. I didn't think about getConvertedInput being called multiple times. I'm working on a refactoring now. Removing final from getConvertedInput wasn't the smartest thing to do it turns out. I'm thinking about making that method final again, and instead removing final from convert (and rename that to convertInput) and add setConvertedInput. You can then override convertInput and call setConvertedInput with the new value, and be sure this method will only be called once. Eelco - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Use getConverterInput rather than updateModel in FormComponentPanel
Eelco Hillenius wrote: > > When fixing issues 500[1] and 522[2] I found that the best way of > fixing this is to override getConvertedInput (which was declared as > final). For anyone using FormComponentPanel, please take note that if > you want this component to work properly with validators and form > validators you should override getConvertedInput rather then > updateModel. Please see the implementations of DateField and > DateTimeField and the updated JavaDoc of FormComponentPanel. > I am making a ComboBox component that extends FormComponentPanel. I did as you said, and I override getConvertedInput(), but the body of the method scans a List to find a matching item. With only a few items, this isn't too bad, but I'm afraid of performance problems as the list size grows. Also, that method is already called twice and I am planning on writing a Validator for it, which will cause it to be called at least three times per update cycle. I was wondering if you could suggest a caching strategy for me to try? I can store the converedInput on the Component, but what about cleaning up that cached value? Will I need to worry about stale data being returned by getConvertedInput? or will the Component's normal lifecycle protect me from that? Thanks for any insight you can offer. Chuck -- View this message in context: http://www.nabble.com/Use-getConverterInput-rather-than-updateModel-in-FormComponentPanel-tf3873952.html#a11395618 Sent from the Wicket - User mailing list archive at Nabble.com. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Use getConverterInput rather than updateModel in FormComponentPanel
On 6/6/07, Johan Compagner <[EMAIL PROTECTED]> wrote: > Its a pitty that we cant do this in FormComponentPanel: > > > /** > * @see > org.apache.wicket.markup.html.form.FormComponent#getConvertedInput() > */ > public abstract Object getConvertedInput(); > > > then we force everybody to think about it.. > But you can't do then super.getConvertedInput() :( (because the compiler > thinks it is abstract which is not really the case..) > > updateModel is more for modifying again the convertedinput to the model. > (like merging list) > Do we have more components that we should check? Like MultiFileUploadField? Dunno. Basically, everything that extends FormComponentPanel. Eelco - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Use getConverterInput rather than updateModel in FormComponentPanel
Its a pitty that we cant do this in FormComponentPanel: /** * @see org.apache.wicket.markup.html.form.FormComponent#getConvertedInput() */ public abstract Object getConvertedInput(); then we force everybody to think about it.. But you can't do then super.getConvertedInput() :( (because the compiler thinks it is abstract which is not really the case..) updateModel is more for modifying again the convertedinput to the model. (like merging list) Do we have more components that we should check? Like MultiFileUploadField? johan On 6/5/07, Eelco Hillenius <[EMAIL PROTECTED]> wrote: Hi, When fixing issues 500[1] and 522[2] I found that the best way of fixing this is to override getConvertedInput (which was declared as final). For anyone using FormComponentPanel, please take note that if you want this component to work properly with validators and form validators you should override getConvertedInput rather then updateModel. Please see the implementations of DateField and DateTimeField and the updated JavaDoc of FormComponentPanel. Cheers, Eelco [1] http://issues.apache.org/jira/browse/WICKET-522 [2] http://issues.apache.org/jira/browse/WICKET-500 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
[Wicket-user] Use getConverterInput rather than updateModel in FormComponentPanel
Hi, When fixing issues 500[1] and 522[2] I found that the best way of fixing this is to override getConvertedInput (which was declared as final). For anyone using FormComponentPanel, please take note that if you want this component to work properly with validators and form validators you should override getConvertedInput rather then updateModel. Please see the implementations of DateField and DateTimeField and the updated JavaDoc of FormComponentPanel. Cheers, Eelco [1] http://issues.apache.org/jira/browse/WICKET-522 [2] http://issues.apache.org/jira/browse/WICKET-500 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user