Re: Issue while adding Custom Validator to ListMultipleChoice component

2012-12-28 Thread Sven Meier

Hi,

>This is getting empty when it is loaded with default values.

You mean you have values in your model but they don't show up on a 
re-submit?


Please take a look at ListMultipleChoicePage in wicket-examples. If I 
add a validator there, everything works as expected:


listChoice.add(new IValidator>()
{
@Override
public void validate(IValidatable> 
validatable)

{
Collection value = validatable.getValue();
// value is filled with the now selected choices
}
});

Check what's different to your usage.

Sven

On 12/28/2012 11:10 AM, wicket_new_user wrote:

thanks Sven for your reply. the syntax issue worked.

But i'm, getting another probelm is

final Collection selectedFields = validatable.getValue();

This is getting empty when it is loaded with default values. Not sure if i'm
missing anything to add here.



Able to get the values only when the values or added to the list (i.e, the
component gets modified)



Also, I have observed that, in onSubmit(), the "updateModel()" iof
ListMultipleChoice() s getting called to set the actual property values, and
so the values are being displayed in in on submit when storing them in
domain objects :-(.
But it is not the case in Validating it :-(

Thanks
WN







--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Issue-while-adding-Custom-Validator-to-ListMultipleChoice-component-tp4655091p4655093.html
Sent from the Users forum 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: Issue while adding Custom Validator to ListMultipleChoice component

2012-12-28 Thread Sven Meier

The generic type of your validator should be:

  public class SelectedAttributesValidator implements 
IValidator>


Sven

On 12/28/2012 09:41 AM, wicket_new_user wrote:

Hi,
is it possible to add Custom Validator (implenting IValidator) for
ListMultipleChoice component?

when i'm trying to add validator to the the componnent using the below code,

final ListMultipleChoice selectedFields = new
ListMultipleChoice("selected",
 new ListModel(new ArrayList()),
availableAttributesModel,
 FIELD_RENDERER);

selectedFields.setOutputMarkupId(true);
s*electedFields.add(new SelectedAttributesValidator());*

i'm seeing the below compilation error for the above statement
*The method add(IValidator>) in the type
FormComponent> is not applicable for the arguments
(SelectedAttributesValidator)*


Following is the Validator Class
=
public class SelectedAttributesValidator implements
IValidator>
{

 /**
  *
  */
 private static final long serialVersionUID = 1L;

 /**
  *
  */
 public void validate(IValidatable>
validatable)
 {
 final ListMultipleChoice selectedFields =
validatable.getValue();

 if (CollectionUtils.isEmpty(selectedFields.getChoices()))
 {
 validatable.error(new
ValidationError().addMessageKey("attributesMustBeSelected"));
 }

 }

}

the reason i'm going for Custom Validator is as i'm unable to get the value
from the "getConvertedInput()" as it is showing always empty, when the form
is loaded with default values. Not able to understand what could be the
problem.


can one please let me know, if there is any issue in the above code?

Thanks




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Issue-while-adding-Custom-Validator-to-ListMultipleChoice-component-tp4655091.html
Sent from the Users forum 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