[英]What's the best way of rendering component specific error messages?
I need a general way of rendering a component specific error message right next to the component which caused it. 我需要一种在导致错误的组件旁边呈现特定于组件的错误消息的通用方法。 Up to now I've used a Feedback panel, which isn't ideal if the page contains multiple components, requiring the user to scroll down the page.
到目前为止,我已经使用了“反馈”面板,如果页面包含多个组件,这是不理想的,这要求用户向下滚动页面。 Also, if you place multiple Feedback panels on the page, they all display the same message.
另外,如果您在页面上放置多个“反馈”面板,它们都将显示相同的消息。 Is there a general way of rendering localised error messages near a specific component?
是否存在在特定组件附近呈现本地化错误消息的一般方法?
You can place multiple feedback panels on a page with different sets of messages. 您可以在页面上放置多个带有不同消息集的反馈面板。 The
FeedbackPanel
class has a constructor that takes an IFeedbackMessageFilter , and you can create your own implementations of this filter to limit the messages that will show. FeedbackPanel
类具有一个接受IFeedbackMessageFilter的构造函数,您可以创建此过滤器的自己的实现,以限制将显示的消息。
To more completely localize your messages to appear next to the related form components, you can use a FormComponentFeedbackBorder . 要更完全地本地化要显示在相关表单组件旁边的消息,可以使用FormComponentFeedbackBorder 。 A good example of combining these to make a form show messages in a regular feedback panel but also highlight the bad fields is shown in this blog post .
在此博客文章中显示了一个很好的例子,可以将这些结合起来以使表单在常规反馈面板中显示消息,同时突出显示不良字段。
There is an Excellent Blog post on this subject from a few years back. 几年前,有一篇关于该主题的优秀博客文章。
That details how to have error messages show up next to the component that reported the error. 这详细说明了如何使错误消息显示在报告错误的组件旁边。
http://stuq.nl/weblog/2008-09-03/user-friendly-form-validation-with-wicket http://stuq.nl/weblog/2008-09-03/user-friendly-form-validation-with-wicket
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.