Hi all,

I've the following component heirarchy:

form:textField
form:listView:panel-1:panel1DropDownChoice
form:submitButton

I've marked the all the form components as required.

I also have a behavior that is added to all the form components (via
IVisitor) which will make the respective feedback messages appear under the
form components.

It works perfectly for the form component "texField" which is directly
attached to the form.

However it doesn't work for for "panel1DropDownChoice".

I've added some debug messages in the "validate()" method of
"panel1DropDownChoice" and found that feedback messages are indeed
generated.

However from the debug messages in my behavior, I found that feedback
messages were some how lost.

This is the behavior I'm using. (Thanks London Wicket users)

*public class ValidationMsgBehavior extends Behavior
{
    private static Logger logger =
LoggerFactory.getLogger(ValidationMsgBehavior.class);

    @Override
    public void afterRender(Component c)
    {
        logger.debug("Preparing to add validation msg for the component
{}", c);
        FormComponent fc = (FormComponent) c;
        if (!fc.isValid()) {
            String error;
            if (fc.hasFeedbackMessage()) {
                logger.debug("Form component {} has feedback messages", fc);
                error =
fc.getFeedbackMessages().first(FeedbackMessage.ERROR).getMessage().toString();
            } else {
                error = "Your input is invalid.";
            }
            fc.getResponse().write(
                    "<div class=\"text-error\">" + error + "</div>");
        }else{
            logger.debug("Form component {} is valid", fc);
        }
    }
}*

Any clues? I've been trying to crack this for a whole day.

-- 
Thanks & regards
James Selvakumar

Reply via email to