Hello,
I have problem with DropDownChoice components. I have three DDC
components which loads child component choices when you change parents
value. This work, but one thing not - when I back to "Choose" choice
the Ajax request returns empty and it's because
onUpdate(AjaxRequestTarget target) is not invoked in this case.
When I remove required from parent DDC it works (nulls the chocies of
child), but I need required and show errors when submit form. I have
tried to validate component but it was validated after other
components with setRequired() set up so no show if them aren't filled
with good values.
This validating was done by such code:
_carModelDDC.add(new AbstractValidator(){
                        @Override
                        protected void onValidate(IValidatable component) {
                                if(((DropDownChoice) 
component).getModelObject() == null){
                                        error(component, 
getString(CAR_MODEL_REQUIRED));
                                }
                        }
});

Component code which not working with null values is coded like that:
DropDownChoice _carMarkDDC = new DropDownChoice(CAR_MARK,
carMarkDAO.getAllCarMarks());
                _carMarkDDC.setRequired(true);
                _carMarkDDC.add(new 
AjaxFormComponentUpdatingBehavior(ONCHANGE_BEHAVIOR) {
                        protected void onUpdate(AjaxRequestTarget target) {
                                carPartsModel.setCarModel(null);
                                if(carPartsModel.getCarMark() != null) {
                                        CarMark carMark = 
carPartsModel.getCarMark();
                                        carModelDDC.setChoices(new 
ArrayList<CarModel>
(carMarkDAO.getCarModels(carMark)));
                                        carModelDDC.setEnabled(true);
                                } else {
                                        
carModelDDC.setChoices(Collections.EMPTY_LIST);
                                        carModelDDC.setEnabled(false);
                                }
                                target.addComponent(carModelDDC);
                        }
                });

Any possible clues for that?
Best regards,
Adr

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to