You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Chris <ch...@carlsoncentral.com> on 2009/04/07 16:53:02 UTC

Validating DropDownChoice

I have a DropDownChoice defined as follows.

// Model for populating Condition Dropdown
IModel conditions = new LoadableDetachableModel() {
  public Object load() {
  List<Conditions> c = new ArrayList();
  try {
    c = dao.getConditions();
  } catch (DaoException e) { }
    return c;
  }
};

// Condition Dropdown
DropDownChoice condition = new DropDownChoice("conditions", conditions);
ChoiceRenderer choiceRenderer = new ChoiceRenderer("condition", 
"condition");
add(new DropDownChoice("name", conditions, choiceRenderer));


Trying to write a custom AbstractFormValidator which makes the 
DropDownChoice or a TextField required.  The problem is in my validate() 
method the DropDownChoice is always null.

 public void validate(Form form) {
        FormComponent f1 = components[0];
        String f1Value = Objects.stringValue(f1.getConvertedInput(), true);

I also tried f1.getInput(), f1.getModelObject() and just about every 
other FormComponent method.  What is the proper way to grab the 
DropDownChoice selected value?  Im using wicket-1.4-SNAPSHOT if that 
matters.



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


AW: Validating DropDownChoice

Posted by Stefan Lindner <li...@visionet.de>.
Is it a "normal" form without AjaxSubmitButton?

-----Ursprüngliche Nachricht-----
Von: Chris [mailto:chris@carlsoncentral.com] 
Gesendet: Dienstag, 7. April 2009 16:53
An: users@wicket.apache.org
Betreff: Validating DropDownChoice

I have a DropDownChoice defined as follows.

// Model for populating Condition Dropdown
IModel conditions = new LoadableDetachableModel() {
  public Object load() {
  List<Conditions> c = new ArrayList();
  try {
    c = dao.getConditions();
  } catch (DaoException e) { }
    return c;
  }
};

// Condition Dropdown
DropDownChoice condition = new DropDownChoice("conditions", conditions);
ChoiceRenderer choiceRenderer = new ChoiceRenderer("condition", 
"condition");
add(new DropDownChoice("name", conditions, choiceRenderer));


Trying to write a custom AbstractFormValidator which makes the 
DropDownChoice or a TextField required.  The problem is in my validate() 
method the DropDownChoice is always null.

 public void validate(Form form) {
        FormComponent f1 = components[0];
        String f1Value = Objects.stringValue(f1.getConvertedInput(), true);

I also tried f1.getInput(), f1.getModelObject() and just about every 
other FormComponent method.  What is the proper way to grab the 
DropDownChoice selected value?  Im using wicket-1.4-SNAPSHOT if that 
matters.



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


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