Question

I am developing an application and I want to display informational messages to the frontend webpage like "new record has been added or deleted or updated" etc. I want the message to disappear after few seconds ( may be 10-15 seconds).

How to approach it ? The application is being developed in Apache Wicket1.5.

Thanks in advance.

Was it helpful?

Solution

[Edit]: this is for Wicket 1.6.. Wicket 1.5 is a bit trickier. I will look into it later.

I would recommend making a Wicket component for this; and adding Jquery javascript when the component needs to be rendered.

You can use http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/markup/head/OnDomReadyHeaderItem.html

  @Override
    public void renderHead(IHeaderResponse response) {
        response.render(OnDomReadyHeaderItem.forScript(yourMethod(..., component.getMarkupId())));
    } 

I think Wicket 1.5 offers similar approachs

OTHER TIPS

For a pure wicket approach, you could attach an AjaxSelfUpdatingTimerBehavior. In the onTimer method you could set the message to invisible and stop() the timer.

Another way would be to implement this in JavaScript.

Before I saw the responses, I did a simple trick.

The primary requirement is to show an informational message for a short time. So I used

            pr.getPage().info("Records details are updated successfully!");
            setResponsePage(pr.getPage());

pr is the PageReference object passed from the previous page.

The messages were displayed on the FeedbackPanel in the next page and I used a timer to reload the page after 10 seconds. So the message disappears.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top