I have an IFeedback
component on my html, and it shows messages if something happens, etc: I upload a file, and a message will inform me: 1 file upload successfully
. And what I want is to close this message peace. How could I do it? If I refresh the page, the message will disappear, but I want to create a button, or a link, to click on it, and than the message will close/disappear. Can anyone give me an example, or some help?
You can add an AjaxEventBehavior
that add's a click
handler to your component and when it's clicked it will disappear. Here example code with an FeedbackPanel
:
private FeedbackPanel feedbackPanel() {
final FeedbackPanel fb = new FeedbackPanel("feedbackPanel") {
@Override
protected void onConfigure() {
super.onConfigure();
setVisible(anyMessage());
}
};
fb.add(new AjaxEventBehavior("click") {
@Override
protected void onEvent(AjaxRequestTarget target) {
fb.setVisible(false);
target.add(fb);
}
});
fb.setOutputMarkupPlaceholderTag(true);
return fb;
}