wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonio Mauriello <antoniomau...@gmail.com>
Subject issue using executeAjaxEvent for a test
Date Tue, 07 Sep 2010 11:02:55 GMT
Hi All,

I have an issue trying to test an ajax event.

I have two different wicket classes which need to talk each other.
Both classes have a TextField plus a ListMultipleChoice. When the user
types a word into the class A textField the items of the class A list
get filtered and, based on
the new class A list choices, the class B list gets filtered as well.

To achieve that I have the following on the class A textField

//Class A
new OnChangeAjaxBehavior()
        {
            /**
			 *
			 */
			private static final long serialVersionUID = 1L;

			@Override
            protected void onUpdate(AjaxRequestTarget target)
            {
				
[12]          listMultipleChoice.setDefaultModelObject(getValue(txtField.getDefaultModelObjectAsString()));
		List<String> selectedClassAItems = getSelected();
            	classB.filterByClassAItems(selectedClassAItems);
                target.addComponent(classB.getListMultipleChoice());
                target.addComponent(listMultipleChoice);
            }
        };

		
which actually it's working fine.

To test it I have the following

		textField<String> classATextField = (TextField<String>)
classAWicketTester.getComponentFromLastRenderedPage("panel:ajaxMultiChoiceform:filterBox");
		classATextField.setDefaultModelObject("filtered");
		classAWicketTester.executeAjaxEvent(classATextField.getPageRelativePath(),
"onchange");
				
		ListMultipleChoice<String> classAItems =
(ListMultipleChoice<String>)
classAWicketTester.getComponentFromLastRenderedPage("panel:ajaxMultiChoiceform:filteredList");

		assertEquals("[filteredItem]", classAItems.getChoices().toString());
		ListMultipleChoice<String> classBItems =
(ListMultipleChoice<String>)
classBWicketTester.getComponentFromLastRenderedPage("panel:ajaxMultiChoiceform:filteredList");
		assertEquals("[filteredClassBItem]", classBItems.getChoices().toString());



###########

Now the issue is that for some reason using the executeAjaxEvent, to
fire the onchange event, the model into
txtField.getDefaultModelObjectAsString() (line 12) is always null
hence I cannot retrieve the text value set and filter both lists.

I've checked during the debugging the ids of the component and they
are exactly the same, so I'm sure the textField called here in line 12
is the same one used to set
classATextField.setDefaultModelObject("filtered");
but for some reason even if it's the same the model is null.

Any clue? Is executeAjaxEvent enough the fire the onUpdate?


Regards
Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Mime
View raw message