Re: Form Validations
FeedbackLabel.onBeforeRender calls setModel(IModel) but wicket 1.4 doesn't seem to have this method. protected void onBeforeRender() { super.onBeforeRender(); this.setModel(null); if(component.getFeedbackMessage()!=null){ if(this.text!=null){ this.setModel(text); } else { this.setModel(new Model(component.getFeedbackMessage().getMessage())); } this.add(new AttributeModifier(class, true, new Model(feedbacklabel + component.getFeedbackMessage().getLevelAsString(; } else { this.setModel(null); } } -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Form-Validations-tp1879918p3079456.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Form Validations
Nevermind--I see that setModel is now setDefaultModel. See article comments: http://stuq.nl/weblog/2008-09-03/user-friendly-form-validation-with-wicket -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Form-Validations-tp1879918p3079482.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Form Validations
I am using Wicket-1.3.0 Version. Following are the code Snippet //Code Snippet for RadioChoice// RadioGroup sexField = new RadioGroup(sex, new Model()); sexField.add(new Radio(male, new Model(Male))); sexField.add(new Radio(female, new Model(Female))); sexField.setOutputMarkupId(true); sexField.setRequired(true); add(sexField); final FeedbackLabel sexFeedbackLabel = new FeedbackLabel(sexFeedback, sexField); sexFeedbackLabel.setOutputMarkupId(true); add(sexFeedbackLabel); //Code Snippet for AutoCompleteTextField// AutoCompleteTextField cityField = new AutoCompleteTextField(city, new Model()) { @Override protected Iterator getChoices(String input) { if (Strings.isEmpty(input)) { return Collections.EMPTY_LIST.iterator(); } List choices = new ArrayList(); List name = reader.loadFile(cities.txt);//cities.txt contains cities name... Iterator itr = name.iterator(); while (itr.hasNext()) { String nameIs = (String) itr.next(); if (nameIs.toUpperCase().startsWith(input.toUpperCase())) { choices.add(nameIs); if (choices.size() == 10) { break; } } } return choices.iterator(); } }; cityField.setOutputMarkupId(true); cityField.setRequired(true); cityField.add(new StringValidator.MaximumLengthValidator(25)); final FeedbackLabel cityLabel = new FeedbackLabel(cityFeedback, cityField); cityLabel.setOutputMarkupId(true); add(cityLabel); cityField.add(new ComponentVisualErrorBehavior(onblur, cityLabel)); add(cityField); Label citLabel = new Label(city.label, City); add(citLabel); Thank you -- View this message in context: http://www.nabble.com/Form-Validations-tp22777684p22799307.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Form Validations
Hi Ashish, Do you use AJAX? Have you added the components to the AjaxRequestTarget with target.addComponent() ? If you do use AJAX, you have to override both onError and onSubmit on the AjaxButton you use for submit. In both these methods you have to add the relevant components to the AjaxRequestTarget, or else they won't get updated. Something like: form.add(new AjaxButton(saveButton){ protected void onSubmit(AjaxRequestTarget target, Form form) { target.addComponent(sexFeedbackLabel); target.addComponent(cityLabel); // If you change other components, add them to the target as well. } @Override protected void onError(AjaxRequestTarget target, Form form) { target.addComponent(sexFeedbackLabel); target.addComponent(cityLabel); } }); It is possible that I guessed completely wrong about your problem :-) If you like, I can update the demo project with a working AJAX sample. By the way, the blog post and demo project is all based on Wicket 1.3.4, so it is possible that this will not work for previous versions. Regards, Daan Op 31 mrt 2009, om 08:46 heeft Ashis het volgende geschreven: I am using Wicket-1.3.0 Version. Following are the code Snippet //Code Snippet for RadioChoice// RadioGroup sexField = new RadioGroup(sex, new Model()); sexField.add(new Radio(male, new Model(Male))); sexField.add(new Radio(female, new Model(Female))); sexField.setOutputMarkupId(true); sexField.setRequired(true); add(sexField); final FeedbackLabel sexFeedbackLabel = new FeedbackLabel(sexFeedback, sexField); sexFeedbackLabel.setOutputMarkupId(true); add(sexFeedbackLabel); //Code Snippet for AutoCompleteTextField// AutoCompleteTextField cityField = new AutoCompleteTextField(city, new Model()) { @Override protected Iterator getChoices(String input) { if (Strings.isEmpty(input)) { return Collections.EMPTY_LIST.iterator(); } List choices = new ArrayList(); List name = reader.loadFile(cities.txt);// cities.txt contains cities name... Iterator itr = name.iterator(); while (itr.hasNext()) { String nameIs = (String) itr.next(); if (nameIs.toUpperCase().startsWith(input.toUpperCase())) { choices.add(nameIs); if (choices.size() == 10) { break; } } } return choices.iterator(); } }; cityField.setOutputMarkupId(true); cityField.setRequired(true); cityField.add(new StringValidator.MaximumLengthValidator(25)); final FeedbackLabel cityLabel = new FeedbackLabel(cityFeedback, cityField); cityLabel.setOutputMarkupId(true); add(cityLabel); cityField.add(new ComponentVisualErrorBehavior(onblur, cityLabel)); add(cityField); Label citLabel = new Label(city.label, City); add(citLabel); Thank you -- View this message in context: http://www.nabble.com/Form-Validations-tp22777684p22799307.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Form Validations
Hello all I have a problem with a form, I want to add a feedBackPanel for each fields added in my form. I used the custom FeedbackLabel i.e. http://stuq.nl/weblog/2008-09-03/user-friendly-form-validation-with-wicket But it did not worked on AutoCompleteTextFields and RadioChoice. Any Help -- View this message in context: http://www.nabble.com/Form-Validations-tp22777684p22777684.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Form Validations
What didn't work? -- Jeremy Thomerson http://www.wickettraining.com On Mon, Mar 30, 2009 at 2:31 AM, Ashis chettri.as...@gmail.com wrote: Hello all I have a problem with a form, I want to add a feedBackPanel for each fields added in my form. I used the custom FeedbackLabel i.e. http://stuq.nl/weblog/2008-09-03/user-friendly-form-validation-with-wicket But it did not worked on AutoCompleteTextFields and RadioChoice. Any Help -- View this message in context: http://www.nabble.com/Form-Validations-tp22777684p22777684.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org