Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3362700
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:18:22+00:00 2026-05-18T03:18:22+00:00

EDIT: This question was originally about checkboxes, but I am getting the same behavior

  • 0

EDIT:
This question was originally about checkboxes, but I am getting the same behavior with a dropdown list. The code:

productInput = new DropDownChoice<String>("productInput",
                                          new PropertyModel<String>(this, "productSelection"),
                                          products);

productInput.add(new AjaxFormComponentUpdatingBehavior("onchange") {
    @Override
    protected void onUpdate(AjaxRequestTarget target)
    {
        if (productSelection == null) // Breakpoint is set on this line
        {
            updateDropdownsAfterFieldDisabled(1, target);
        }
        else
        {
            updateDropdownsAfterFieldEnabled(1, target);
        }
    }
});

If productInput is not set to required, the breakpoint gets hit every time the list goes from having some value selected to having the blank line option selected. If it is set to required, the breakpoint never gets hit.


Is it possible to dynamically/AJAX-ishly change a Wicket form component if it’s being validated with setRequired(true);? Here’s a simple, if contrived, example to show what I mean:

Drive-through carwashes at gas stations usually often three or four levels of service. Each one includes everything provided by the lower levels and tacks on one more coat of wax or an extra rinse or something. UIs for the washes usually have four buttons with lights next to them (example). When a user presses one of the buttons, the corresponding light turns on, along with all the lights of the cheaper levels; the lights for nicer levels turn off. That behavior is modeled by this code:

boolean economy, standard, deluxe, ultimate = false;

CheckBox economyBox = new CheckBox("economyBox",
                                   new PropertyModel<Boolean>(this, "economy"));
// Similar declarations for standardBox, deluxeBox and ultimatebox

OnChangeAjaxBehavior standardChangeListener = new OnChangeAjaxBehavior() {
    protected void onUpdate(AjaxRequestTarget target)
    {
        // If "standard" is activated, also turn on the "economy" light
        if (standard)
        {
            economy = true;
            target.addComponent(economyBox);
        }
        // If "standard" is deactivated, deactivate "deluxe" and "ultimate"
        else if (!standard)
        {
            deluxe = false;
            ultimate = false;
            target.addComponent(deluxeBox);
            target.addComponent(ultimateBox);
        }
    }
};
standardBox.add(standardChangeListener);
// Similar listeners declared for the other three checkboxes

I’ve tested this code — well, the real code that this is a simplified version of — and it works as expected. But add in economyBox.setRequired(true); and the box stops updating dynamically. Is there a way to add validation without breaking the “linked checkbox” behavior?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T03:18:23+00:00Added an answer on May 18, 2026 at 3:18 am

    I can’t see anything wrong here except you have

            target.addComponent(standardBox);
    

    where I think you intended

            target.addComponent(economyBox);
    

    Validation should interoperate with OnChangeAjaxBehavior just fine. I’m quite sure I’ve used both in some forms, though not I think with checkboxes.

    I’m not sure the idea of validation with economyBox.setRequired(true); makes sense here though. You’re supplying values, defaulting to false for all the checkboxes, in your model, so there’s no real way for anything to be actually omitted in this context.

    A more sensible validation might be that something has to be checked, but that would require a different validator defined for the form as a whole, or for a FormComponent incorporating all your checkboxes.

    EDIT:
    Based on your edit about seeing the same issue with DropDownChoice, I did an experiment.

    There is an example of AjaxFormComponentUpdatingBehavior with DropDownChoice components here. I downloaded the code for this, added

        models.setRequired(true);
        makes.setRequired(true);
        add(new FeedbackPanel("messages"));
    

    and of course added markup for the feedback panel.

    It validated the required fields and continued to update the model drop-down based on the value of the make dropdown.

    Since this worked fine for me, I’d recommend you try the same, see it work and then compare with your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: This question is more about language engineering than C++ itself. I used C++
(EDIT: This question is now outdated for my particular issue, as Google Code supports
Edit: This question was written in 2008, which was like 3 internet ages ago.
EDIT : This question duplicates How to access the current Subversion build number? (Thanks
I'm using markdown to edit this question right now. In some wikis I used
[EDIT] Hmm. Perhaps this question should be titled what is the default user-input dialog
Edit: This was accidentally posted twice. Original: VB.NET Importing Classes I've seen some code
Edit: This code is fine. I found a logic bug somewhere that doesn't exist
EDIT: This was formerly more explicitly titled: - Best solution to stop Kontiki's KHOST.EXE
Edit: This is a confirmed bug in jQuery 1.3.1. It is fixed in jQuery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.