Hi all, I have a form with a TextField component and a DropDownChoice component. The DropDownChoice component has an AjaxFormComponentUpdatingBehavior("onchange") behavior added.
What I would like to do is to change the color of the text in the TextField component whenever a DropDownChoice component selection changes. Everything works fine except of that the text in the TextField component is reseted to an empty string (that is inital value) each time the TextField component is added to AjaxRequestTarget parameter in onUpdate(AjaxRequestTarget) method. How to preserve the text value in TextField component and only change the color of the text? Here is a relevant code snippet: --- final TextField textField = new TextField("categoryName", new PropertyModel(categoryModel, "name")); textField.setOutputMarkupId(true); textField.add(new AttributeModifier("style", true, new Model() { public Object getObject(Component component) { if (category.getType() == CategoryType.HIGH) return "color:blue;"; else if (category.getType() == CategoryType.LOW) return "color:red;"; else return null; } })); add(textField); DropDownChoice dropDownChoice = new DropDownChoice("categoryType", new PropertyModel(categoryModel, "type"), Arrays.asList(CategoryType.values()), new CategoryTypeChoiceRenderer()); dropDownChoice.add( new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { target.addComponent(textField); } }); add(dropDownChoice); --- Thanks, Dominik ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user