RE: DropDownChoice in FormComponentPanel

2013-05-20 Thread Paul Bors
Be careful as getModelObject() returns the model object of the form field
after the form has been processed (since that's when it's updated).

convertInput() is used to take the rawInput as text and convert it to the
Java type and then used to validate the user input which will not end up in
the model object if validation fails.

If you use getModelObject() your user input will be reset each time an error
occurs and the user would have to input the selection over and over which is
annoying for forms that have many form fields (since the each error field
will be reset).

For more on how Wicket processes see the From JavaDoc:
http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/markup/
html/form/Form.html
http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/markup/
html/form/FormComponent.html#convertInput()

~ Thank you,
  Paul Bors

-Original Message-
From: Richard W. Adams [mailto:rwada...@up.com] 
Sent: Monday, May 20, 2013 12:54 PM
To: users@wicket.apache.org
Subject: RE: DropDownChoice in FormComponentPanel

I'm not finished investigating this yet, but my preliminary findings
indicate that the solution (at least in my case) is to call
dropdown.getModelObject() instead of dropdown.convertInput(). In the use
cases I've tested so far, getModelObject() returns the correct value.




From:   Paul Bors 
To: 
Date:   05/20/2013 11:35 AM
Subject:    RE: DropDownChoice in FormComponentPanel



Simplest way I can think of is something like:

@Override
protected void onBeforeRender() {
  if(isValid()) {
dropDown.getFormField().setDefaultModel(getDefaultModel());
  }
  ...
  super.onBeforeRender();
}

@Override
protected void convertInput() {
  if(dropdown != null) {
setConvertedInput(dropDown.getConvertedInput());
  }
  ...
}

But it really depends on what your FormComponentPanel is wrapping and how
you share its model among the child components.

Refer to the Wicket Users Guide section 1.8 "Creating comples form
components with FormComponentPanel":
http://wicket.apache.org/learn/books/freeguide.html

Or search the wiki pages:
https://cwiki.apache.org/WICKET/creating-custom-formcomponentpanels-to-build

-valid-objects-using-wickets-form-validation-logic.html

~ Thank you,
  Paul Bors
 

-Original Message-
From: Richard W. Adams [mailto:rwada...@up.com]
Sent: Monday, May 20, 2013 8:10 AM
To: users@wicket.apache.org
Subject: DropDownChoice in FormComponentPanel

I have a FormComponentPanel with both string fields & DropDownChoice
controls. How do I get the drop downs' current selections from inside my
override of convertInput()?

I can get the string fields' values by calling the fields' convertInput()
methods, but when I call convertInput() on the drop downs, I get the
ORIGINAL value of the drop down, not the CURRENT value. I'm using Wicket
1.4.17 (version imposed by our corporate framework).

I've looked at several different Wicket references, including Wicket in
Action, Apache Wicket Cookbook & the new online free Wicket guide, but could
not find this issue discussed.

**

This email and any attachments may contain information that is confidential
and/or privileged for the sole use of the intended recipient.  Any use,
review, disclosure, copying, distribution or reliance by others, and any
forwarding of this email or its contents, without the express permission of
the sender is strictly prohibited by law.  If you are not the intended
recipient, please contact the sender immediately, delete the e-mail and
destroy all copies.
**


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




**

This email and any attachments may contain information that is confidential
and/or privileged for the sole use of the intended recipient.  Any use,
review, disclosure, copying, distribution or reliance by others, and any
forwarding of this email or its contents, without the express permission of
the sender is strictly prohibited by law.  If you are not the intended
recipient, please contact the sender immediately, delete the e-mail and
destroy all copies.
**


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



RE: DropDownChoice in FormComponentPanel

2013-05-20 Thread Richard W. Adams
I'm not finished investigating this yet, but my preliminary findings 
indicate that the solution (at least in my case) is to call
dropdown.getModelObject() instead of dropdown.convertInput(). In the use 
cases I've tested so far, getModelObject() returns the correct value.




From:   Paul Bors 
To: 
Date:   05/20/2013 11:35 AM
Subject:    RE: DropDownChoice in FormComponentPanel



Simplest way I can think of is something like:

@Override
protected void onBeforeRender() {
  if(isValid()) {
dropDown.getFormField().setDefaultModel(getDefaultModel());
  }
  ...
  super.onBeforeRender();
}

@Override
protected void convertInput() {
  if(dropdown != null) {
setConvertedInput(dropDown.getConvertedInput());
  }
  ...
}

But it really depends on what your FormComponentPanel is wrapping and how
you share its model among the child components.

Refer to the Wicket Users Guide section 1.8 "Creating comples form
components with FormComponentPanel":
http://wicket.apache.org/learn/books/freeguide.html

Or search the wiki pages:
https://cwiki.apache.org/WICKET/creating-custom-formcomponentpanels-to-build

-valid-objects-using-wickets-form-validation-logic.html

~ Thank you,
  Paul Bors
 

-Original Message-
From: Richard W. Adams [mailto:rwada...@up.com] 
Sent: Monday, May 20, 2013 8:10 AM
To: users@wicket.apache.org
Subject: DropDownChoice in FormComponentPanel

I have a FormComponentPanel with both string fields & DropDownChoice
controls. How do I get the drop downs' current selections from inside my
override of convertInput()?

I can get the string fields' values by calling the fields' convertInput()
methods, but when I call convertInput() on the drop downs, I get the
ORIGINAL value of the drop down, not the CURRENT value. I'm using Wicket
1.4.17 (version imposed by our corporate framework).

I've looked at several different Wicket references, including Wicket in
Action, Apache Wicket Cookbook & the new online free Wicket guide, but 
could
not find this issue discussed.

**

This email and any attachments may contain information that is 
confidential
and/or privileged for the sole use of the intended recipient.  Any use,
review, disclosure, copying, distribution or reliance by others, and any
forwarding of this email or its contents, without the express permission 
of
the sender is strictly prohibited by law.  If you are not the intended
recipient, please contact the sender immediately, delete the e-mail and
destroy all copies.
**


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




**

This email and any attachments may contain information that is confidential 
and/or privileged for the sole use of the intended recipient.  Any use, review, 
disclosure, copying, distribution or reliance by others, and any forwarding of 
this email or its contents, without the express permission of the sender is 
strictly prohibited by law.  If you are not the intended recipient, please 
contact the sender immediately, delete the e-mail and destroy all copies.
**


RE: DropDownChoice in FormComponentPanel

2013-05-20 Thread Paul Bors
Simplest way I can think of is something like:

@Override
protected void onBeforeRender() {
  if(isValid()) {
dropDown.getFormField().setDefaultModel(getDefaultModel());
  }
  ...
  super.onBeforeRender();
}

@Override
protected void convertInput() {
  if(dropdown != null) {
setConvertedInput(dropDown.getConvertedInput());
  }
  ...
}

But it really depends on what your FormComponentPanel is wrapping and how
you share its model among the child components.

Refer to the Wicket Users Guide section 1.8 "Creating comples form
components with FormComponentPanel":
http://wicket.apache.org/learn/books/freeguide.html

Or search the wiki pages:
https://cwiki.apache.org/WICKET/creating-custom-formcomponentpanels-to-build
-valid-objects-using-wickets-form-validation-logic.html

~ Thank you,
  Paul Bors
 

-Original Message-
From: Richard W. Adams [mailto:rwada...@up.com] 
Sent: Monday, May 20, 2013 8:10 AM
To: users@wicket.apache.org
Subject: DropDownChoice in FormComponentPanel

I have a FormComponentPanel with both string fields & DropDownChoice
controls. How do I get the drop downs' current selections from inside my
override of convertInput()?

I can get the string fields' values by calling the fields' convertInput()
methods, but when I call convertInput() on the drop downs, I get the
ORIGINAL value of the drop down, not the CURRENT value. I'm using Wicket
1.4.17 (version imposed by our corporate framework).

I've looked at several different Wicket references, including Wicket in
Action, Apache Wicket Cookbook & the new online free Wicket guide, but could
not find this issue discussed.

**

This email and any attachments may contain information that is confidential
and/or privileged for the sole use of the intended recipient.  Any use,
review, disclosure, copying, distribution or reliance by others, and any
forwarding of this email or its contents, without the express permission of
the sender is strictly prohibited by law.  If you are not the intended
recipient, please contact the sender immediately, delete the e-mail and
destroy all copies.
**


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