Re: How to convert component model object to rendered HTML?

2015-03-05 Thread Thorsten Schöning
Guten Tag Martin Grigorov,
am Donnerstag, 5. März 2015 um 08:47 schrieben Sie:

 You can call formComponent#clearInput() in #onError() callback method.
 This way Wicket will use the last (valid) model value.

This way I would loose the current input of the user?

 You can also set custom model value in #onError() if you need.

My model needs to be a list of unique IDs, I can't change that to a
list of non unique company names.

Looks like I would need something simple like overriding
FormComponent.getValue, which is final... Who does call this method
during the render process? I couldn't find the place, maybe I can hook
the caller.

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning   E-Mail: thorsten.schoen...@am-soft.de
AM-SoFT IT-Systeme  http://www.AM-SoFT.de/

Telefon...05151-  9468- 55
Fax...05151-  9468- 88
Mobil..0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


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



Re: How to convert component model object to rendered HTML?

2015-03-05 Thread Thorsten Schöning
Guten Tag Thorsten Schöning,
am Donnerstag, 5. März 2015 um 18:57 schrieben Sie:

 Looks like I would need something simple like overriding
 FormComponent.getValue, which is final...

I found a simple workaround for me: Override onInvalid and
getInputAsArray, in onInvalid I set an instance flag to note it was
called, call inputChanged and reset the flag. inputChanged calls
getInputAsArray (currently), which I overridden to respect my flag, in
which case I provide my company names instead of the ids. The current
model with ids is available using getConvertedInput and because auf
the validation errors the changed raw input doesn't move forward into
other wicket internals, but only gets rendered in the output.

I know it's hacky, but that's exactly what I need. :-/

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning   E-Mail: thorsten.schoen...@am-soft.de
AM-SoFT IT-Systeme  http://www.AM-SoFT.de/

Telefon...05151-  9468- 55
Fax...05151-  9468- 88
Mobil..0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


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



How to convert component model object to rendered HTML?

2015-03-04 Thread Thorsten Schöning
Hi all,

I have my own subclass of RequiredTextField for very specific reasons
and need to convert input after form submit to a Wicket model and vice
versa from a Wicket model to a form input value in case of errors and
such, when Wicket renders the form with the current values. I have
overridden Component.getConverter and can see that convertToObject of
my implementation is called, but not convertToString. Instead Wicket
renders exactly that data which it got submitted by the form, but is
not what I need to show to the user.

Any idea on where I have a problem? Thanks!

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning   E-Mail: thorsten.schoen...@am-soft.de
AM-SoFT IT-Systeme  http://www.AM-SoFT.de/

Telefon...05151-  9468- 55
Fax...05151-  9468- 88
Mobil..0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


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



Re: How to convert component model object to rendered HTML?

2015-03-04 Thread Martin Grigorov
You can call formComponent#clearInput() in #onError() callback method.
This way Wicket will use the last (valid) model value.
You can also set custom model value in #onError() if you need.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Thu, Mar 5, 2015 at 9:39 AM, Thorsten Schöning tschoen...@am-soft.de
wrote:

 Guten Tag Martin Grigorov,
 am Donnerstag, 5. März 2015 um 08:05 schrieben Sie:

  If the validation fails
  then the *raw* input is rendered to the user and there is no usage of
  #convertToString() because there is no need.

 Thanks, I wasn't aware of this and that explains why it looked like it
 would work in other places, because there I have generated the exact
 same values in convertToString like came from the browser and didn't
 notice that the method wasn't ever called.

 But now I do need to render other values, in case of errors during
 form validation Wicket needs to render other values than came form the
 browser during the submit. Is there any way to do this?

 Some background: I have an Ajax auto complete input which searches
 based on company names, but sends company IDs to Wicket. If other
 forms on the page fail validation, I need to render the former
 searched company names instead of their IDs back into the form. Wicket
 by default renders IDs, because that's what it gets, but I thought I
 can simply change that on the server during the render process somehow
 back to company names.

 Mit freundlichen Grüßen,

 Thorsten Schöning

 --
 Thorsten Schöning   E-Mail: thorsten.schoen...@am-soft.de
 AM-SoFT IT-Systeme  http://www.AM-SoFT.de/

 Telefon...05151-  9468- 55
 Fax...05151-  9468- 88
 Mobil..0178-8 9468- 04

 AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
 AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


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




Re: How to convert component model object to rendered HTML?

2015-03-04 Thread Martin Grigorov
Hi,


On Wed, Mar 4, 2015 at 11:21 PM, Thorsten Schöning tschoen...@am-soft.de
wrote:

 Hi all,

 I have my own subclass of RequiredTextField for very specific reasons
 and need to convert input after form submit to a Wicket model and vice
 versa from a Wicket model to a form input value in case of errors and
 such, when Wicket renders the form with the current values. I have
 overridden Component.getConverter and can see that convertToObject of
 my implementation is called, but not convertToString. Instead Wicket
 renders exactly that data which it got submitted by the form, but is
 not what I need to show to the user.

 Any idea on where I have a problem? Thanks!


FormComponent have two models - the model that every component has and
input (raw  converted).
During form submit processing the raw input (the request parameter as
String) is converted to the type of the model, here #convertToObject() is
used.
Next step in the processing is validation, the converted input is given to
all registered IValidators and if all checks pass then finally the
converted input is set as a model object/value. If the validation fails
then the *raw* input is rendered to the user and there is no usage of
#convertToString() because there is no need.



 Mit freundlichen Grüßen,

 Thorsten Schöning

 --
 Thorsten Schöning   E-Mail: thorsten.schoen...@am-soft.de
 AM-SoFT IT-Systeme  http://www.AM-SoFT.de/

 Telefon...05151-  9468- 55
 Fax...05151-  9468- 88
 Mobil..0178-8 9468- 04

 AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
 AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


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




Re: How to convert component model object to rendered HTML?

2015-03-04 Thread Thorsten Schöning
Guten Tag Martin Grigorov,
am Donnerstag, 5. März 2015 um 08:05 schrieben Sie:

 If the validation fails
 then the *raw* input is rendered to the user and there is no usage of
 #convertToString() because there is no need.

Thanks, I wasn't aware of this and that explains why it looked like it
would work in other places, because there I have generated the exact
same values in convertToString like came from the browser and didn't
notice that the method wasn't ever called.

But now I do need to render other values, in case of errors during
form validation Wicket needs to render other values than came form the
browser during the submit. Is there any way to do this?

Some background: I have an Ajax auto complete input which searches
based on company names, but sends company IDs to Wicket. If other
forms on the page fail validation, I need to render the former
searched company names instead of their IDs back into the form. Wicket
by default renders IDs, because that's what it gets, but I thought I
can simply change that on the server during the render process somehow
back to company names.

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning   E-Mail: thorsten.schoen...@am-soft.de
AM-SoFT IT-Systeme  http://www.AM-SoFT.de/

Telefon...05151-  9468- 55
Fax...05151-  9468- 88
Mobil..0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


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