Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-6069

OnChangeAjaxBehavior does not work if the url contains a request parameter with same name as wicket id

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 6.21.0
    • 7.3.0, 8.0.0-M1, 6.22.0
    • wicket
    • None

    Description

      To demonstrate the issue, create below simple page:

      "HomePage.html"
      <wicket:extend>
        <select wicket:id="choice"></select>
      </wicket:extend>
      
      "HomePage.java"
      public class HomePage extends WebPage {
      	private String choice = "a";
      	
      	@Override
      	protected void onInitialize() {
      		super.onInitialize();
      
      		List<String> choices = new ArrayList<String>();
      		choices.add("a");
      		choices.add("b");
      		add(new DropDownChoice<String>("choice", new IModel<String>() {
      
      			@Override
      			public void detach() {
      			}
      
      			@Override
      			public String getObject() {
      				return choice;
      			}
      
      			@Override
      			public void setObject(String object) {
      				choice = object;
      			}
      			
      		}, choices).add(new OnChangeAjaxBehavior() {
      
      			@Override
      			protected void onUpdate(AjaxRequestTarget target) {
      				System.out.println(choice);
      			}
      			
      		}));		
      	}
      }
      

      This simple page prints out choosed value via OnChangeAjaxBehavior, it works fine if you access the page via http://localhost:8080. However it always prints "null" if you access the page with a request parameter the same name as the wicket id, for instance: http://localhost:8080/?choice=somevalue
      It works again if you use different value for wicket id of the choice component and request parameter.

      Attachments

        1. myproject.zip
          25 kB
          Robin Shine

        Activity

          People

            mgrigorov Martin Tzvetanov Grigorov
            robinshine Robin Shine
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: