Re: How to identify if any of a page's components failed validation after a submit
Ned Collyer wrote: er... form.hasError()? form.onError()? What do you mean by page? - are there lots of forms on the page all with errors? Thanks Ned for pointing out the form’s hasError() and onError(). I could make use of these wtihin my visitor rather looking at all components. But what if an error is created outside a form component? Such as: if (!isPhoneDirectoryAvailble) { Session.get().error(The phone directory is not available at this time…); } Let me explain my need for this. I’m writing a custom Refreshing view item reuse strategy that will redisplay the items as they were submitted if any page errors occur (such as validation). I know there is already an existing ReuseIfModelsEqual strategy, but I cannot make use of it. The reason is my model is many levels deep and is highly complex (hibernate generated) and has its own equals/hashcode strategy (our custom implementation) which will not work for this case and I don’t want to further override them. My custom reuse strategy is rather simple. If a page error occurred in which the page gets redisplayed, it simply makes use of the existing items (and does not try to make use of any new items like the ReuseIfModelsEqual strategy does). So going back to my original question, what is the best way to determine if ANY error was generated on the page during the page submit? -- View this message in context: http://www.nabble.com/How-to-identify-if-any-of-a-page%27s-components-failed-validation-after-a-submit-tp18599562p18611715.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to identify if any of a page's components failed validation after a submit
After a page submit, I need to identify if any components on the page failed validation. I’ve come up with two possible solutions, but they both seem to be workarounds and I'm not 100% they cover all conditions. 1. Traverse the page’s component hierarchy using a custom visitor. protected final boolean isFormComponentsValid() { final Object traversalValObj = visitChildren(new ValidFormComponentVisitor()); if (traversalValObj == IVisitor.STOP_TRAVERSAL) { return false; } return true; } public final class ValidFormComponentVisitor implements IVisitor { public Object component(final Component component) { if (component instanceof FormComponent) { if (!((FormComponent) component).isValid()) { return IVisitor.STOP_TRAVERSAL; } } return IVisitor.CONTINUE_TRAVERSAL; } } 2. Traverse the feedback messages in search of an ERROR. public static final boolean isValidationError() { final IteratorFeedbackMessage messageIterator = Session.get().getFeedbackMessages().iterator(); while (messageIterator.hasNext()) { final FeedbackMessage feedbackMessage = messageIterator.next(); if (feedbackMessage.getLevel() == FeedbackMessage.ERROR) { return true; } } return false; } Is there anything directly built into the framework that will provide me with this information? Any other ideas will be appreciated. Thanks! Louis -- View this message in context: http://www.nabble.com/How-to-identify-if-any-of-a-page%27s-components-failed-validation-after-a-submit-tp18599562p18599562.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
PopupSettings IE6 Permission Denied
When using PopupSettings to throw up a popup with a PDF (from a link), IE6 is sporadically throwing a Permission Denied error. I believe this because of the w.focus() firing prior to the PDF/popup being loaded. Below is the code used to display a help link. When clicked, it throws up a popup with a PDF. Here is my markup: ... wicket:message key=menu-help[help]/wicket:message ... Inside my Application extension: ... getSharedResources().add(help, new ContextRelativeResource(/pdf/help.pdf)); ... Inside my panel: ... final ResourceLink help = new ResourceLink(link-help, new ResourceReference(help)); final PopupSettings popUpSettings = new PopupSettings(PopupSettings.RESIZABLE | PopupSettings.SCROLLBARS).setHeight(800).setWidth(800); help.setPopupSettings(popUpSettings); add(help); ... The following markup is generated: ... if(w.blur) w.focus(); return false; href=../resources/org.apache.wicket.Application/helpHelp ... I found that removing if(w.blur) w.focus(); from the onclick event removes the sporadic JS error and still gives me the desired effect (meaning after the PDF is done loading within the popup, the popup is on top and has focus) I did this with the following: @Override public String getPopupJavaScript() { return super.getPopupJavaScript().replace(if(w.blur) w.focus();, ); } I wasn't able find an open JIRA issue for this. Has anyone else experienced this problem? Also, is this a good example of implementing a ResourceLink? -- View this message in context: http://www.nabble.com/PopupSettings-IE6-%22Permission-Denied%22-tp18405095p18405095.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]