Re: Form skips validation for disabled/not visible components

2009-08-04 Thread nytrus


James Carman-3 wrote:
 
 And, if you want to display the currently-selected thing, then try
 using a label (with a little style to it perhaps).
 
 On Mon, Aug 3, 2009 at 11:23 AM, Igor Vaynbergigor.vaynb...@gmail.com
 wrote:
 use HiddenField instead of a TextField, that way there is no need to
 disable it.

 then the textfield/lookup button can be client-side things that
 populate the hidden field.

 -igor
 

Yes HiddenField is nice stuff! I will use IFormValidator as I've to
re-utilize it in several places. Thank you all!
-- 
View this message in context: 
http://www.nabble.com/Form-skips-validation-for-disabled-not-visible-components-tp24790510p24809865.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Form skips validation for disabled/not visible components

2009-08-03 Thread Nicola Tucci
Hi all! I've a situation where I want the form to validate some hidden or
disabled field.

An example is a text field where the user is not allowed to write directly
but only insert some items from some source, a lookup button (this is
much more flexible than a drop down box!).
I set this component disabled with .setEnabled(false). Now when the form is
validated, the validation for my textfield is skipped (see Form class in
wicket 1.4 rc4):

public static abstract class ValidationVisitor implements
FormComponent.IVisitor
{
public Object formComponent(IFormVisitorParticipant component)
{
if (component instanceof FormComponent)
{
FormComponent? formComponent =
(FormComponent?)component;

Form? form = formComponent.getForm();
if (!form.isVisibleInHierarchy() ||
!form.isEnabledInHierarchy())
{
// do not validate formComponent or any of
formComponent's children
return
Component.IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
}
/** HERE WE SKIP!!! */
if (formComponent.isVisibleInHierarchy() 
formComponent.isValid() 
formComponent.isEnabledInHierarchy())
{
validate(formComponent);
}
}
if (component.processChildren())
{
return Component.IVisitor.CONTINUE_TRAVERSAL;
}
else
{
return
Component.IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
}
}

Now I can override this, as Form.validateComponents() if final. I could only
override Form.onSubmit() and doing an ad-hoc validation (not very good).

Some hint? Thanks folk


Re: Form skips validation for disabled/not visible components

2009-08-03 Thread Eyal Golan
1. If you in control of the input of these disabled fields, why allowing
illegal arguments in the first place?
2. If you can't control the entered values, try use FormValidator. With this
class, you can create your own Validate logic with the desired fields.

Eyal Golan
egola...@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

P  Save a tree. Please don't print this e-mail unless it's really necessary


On Mon, Aug 3, 2009 at 4:06 PM, Nicola Tucci nytrus...@gmail.com wrote:

 Hi all! I've a situation where I want the form to validate some hidden or
 disabled field.

 An example is a text field where the user is not allowed to write directly
 but only insert some items from some source, a lookup button (this is
 much more flexible than a drop down box!).
 I set this component disabled with .setEnabled(false). Now when the form is
 validated, the validation for my textfield is skipped (see Form class in
 wicket 1.4 rc4):

 public static abstract class ValidationVisitor implements
 FormComponent.IVisitor
{
public Object formComponent(IFormVisitorParticipant component)
{
if (component instanceof FormComponent)
{
FormComponent? formComponent =
 (FormComponent?)component;

Form? form = formComponent.getForm();
if (!form.isVisibleInHierarchy() ||
 !form.isEnabledInHierarchy())
{
// do not validate formComponent or any of
 formComponent's children
return
 Component.IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
}
/** HERE WE SKIP!!! */
if (formComponent.isVisibleInHierarchy() 
 formComponent.isValid() 
formComponent.isEnabledInHierarchy())
{
validate(formComponent);
}
}
if (component.processChildren())
{
return Component.IVisitor.CONTINUE_TRAVERSAL;
}
else
{
return
 Component.IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
}
}

 Now I can override this, as Form.validateComponents() if final. I could
 only
 override Form.onSubmit() and doing an ad-hoc validation (not very good).

 Some hint? Thanks folk



Re: Form skips validation for disabled/not visible components

2009-08-03 Thread nytrus


egolan74 wrote:
 
 1. If you in control of the input of these disabled fields, why allowing
 illegal arguments in the first place?
 2. If you can't control the entered values, try use FormValidator. With
 this
 class, you can create your own Validate logic with the desired fields.
 

1. Good observation, but my goal is checking for required fields.
2. That's an idea: I can write my class imlpementing IFormValidator and then
add this to the container form. For checking required fields somethign like
this could work:

public class RequiredFieldsValidator extends AbstractFormValidator {
private ListFormComponents components;

public RequiredFieldsValidator(ListFormComponents components) {
this.components = components;
}

public void validate(Form? form)
{
 for(FormComponent c: components) {
  validateRequired();
 }
}
}

-- 
View this message in context: 
http://www.nabble.com/Form-skips-validation-for-disabled-not-visible-components-tp24790510p24792189.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: Form skips validation for disabled/not visible components

2009-08-03 Thread Igor Vaynberg
use HiddenField instead of a TextField, that way there is no need to disable it.

then the textfield/lookup button can be client-side things that
populate the hidden field.

-igor

On Mon, Aug 3, 2009 at 7:51 AM, nytrusnytrus...@gmail.com wrote:


 egolan74 wrote:

 1. If you in control of the input of these disabled fields, why allowing
 illegal arguments in the first place?
 2. If you can't control the entered values, try use FormValidator. With
 this
 class, you can create your own Validate logic with the desired fields.


 1. Good observation, but my goal is checking for required fields.
 2. That's an idea: I can write my class imlpementing IFormValidator and then
 add this to the container form. For checking required fields somethign like
 this could work:

 public class RequiredFieldsValidator extends AbstractFormValidator {
    private ListFormComponents components;

    public RequiredFieldsValidator(ListFormComponents components) {
        this.components = components;
    }

    public void validate(Form? form)
    {
         for(FormComponent c: components) {
              validateRequired();
         }
    }
 }

 --
 View this message in context: 
 http://www.nabble.com/Form-skips-validation-for-disabled-not-visible-components-tp24790510p24792189.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


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



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



Re: Form skips validation for disabled/not visible components

2009-08-03 Thread James Carman
And, if you want to display the currently-selected thing, then try
using a label (with a little style to it perhaps).

On Mon, Aug 3, 2009 at 11:23 AM, Igor Vaynbergigor.vaynb...@gmail.com wrote:
 use HiddenField instead of a TextField, that way there is no need to disable 
 it.

 then the textfield/lookup button can be client-side things that
 populate the hidden field.

 -igor

 On Mon, Aug 3, 2009 at 7:51 AM, nytrusnytrus...@gmail.com wrote:


 egolan74 wrote:

 1. If you in control of the input of these disabled fields, why allowing
 illegal arguments in the first place?
 2. If you can't control the entered values, try use FormValidator. With
 this
 class, you can create your own Validate logic with the desired fields.


 1. Good observation, but my goal is checking for required fields.
 2. That's an idea: I can write my class imlpementing IFormValidator and then
 add this to the container form. For checking required fields somethign like
 this could work:

 public class RequiredFieldsValidator extends AbstractFormValidator {
    private ListFormComponents components;

    public RequiredFieldsValidator(ListFormComponents components) {
        this.components = components;
    }

    public void validate(Form? form)
    {
         for(FormComponent c: components) {
              validateRequired();
         }
    }
 }

 --
 View this message in context: 
 http://www.nabble.com/Form-skips-validation-for-disabled-not-visible-components-tp24790510p24792189.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


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



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



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



Re: Form skips validation for disabled/not visible components

2009-08-03 Thread Eyal Golan
HiddenField is a good thing to know about :)

Eyal Golan
egola...@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

P  Save a tree. Please don't print this e-mail unless it's really necessary


On Mon, Aug 3, 2009 at 5:23 PM, Igor Vaynberg igor.vaynb...@gmail.comwrote:

 use HiddenField instead of a TextField, that way there is no need to
 disable it.

 then the textfield/lookup button can be client-side things that
 populate the hidden field.

 -igor

 On Mon, Aug 3, 2009 at 7:51 AM, nytrusnytrus...@gmail.com wrote:
 
 
  egolan74 wrote:
 
  1. If you in control of the input of these disabled fields, why allowing
  illegal arguments in the first place?
  2. If you can't control the entered values, try use FormValidator. With
  this
  class, you can create your own Validate logic with the desired fields.
 
 
  1. Good observation, but my goal is checking for required fields.
  2. That's an idea: I can write my class imlpementing IFormValidator and
 then
  add this to the container form. For checking required fields somethign
 like
  this could work:
 
  public class RequiredFieldsValidator extends AbstractFormValidator {
 private ListFormComponents components;
 
 public RequiredFieldsValidator(ListFormComponents components) {
 this.components = components;
 }
 
 public void validate(Form? form)
 {
  for(FormComponent c: components) {
   validateRequired();
  }
 }
  }
 
  --
  View this message in context:
 http://www.nabble.com/Form-skips-validation-for-disabled-not-visible-components-tp24790510p24792189.html
  Sent from the Wicket - User mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 

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