开发者

JSF Clearing facesmessage after each request

I have a reports page that submits user generated queries for data retrieval. When no data exists for the query, I add a facesmessage-"No data" to the session and associate it with the submit button so, it shows up next to the button. When the user modifies the query and resubmits it I want the 'no data' msg to be cleared. I couldn't find a way to do this. I couldn't find any messages in the sessionmap or requestmap, so I couldn't use removemessage(). So, for the time being I am using a hack by setting the facesmessages to blank summary and detail. How do I clear the msg for every query submitted?

Thanks.


BalusC,

Couldn't find a reply button, so I am editing the original post

Here's what I have: JSF 1.2, Richfaces 3.3

The backing bean for my report page is ses开发者_如何学Gosionscoped. The page has a dropdown menu to select report types and a submit button hooked up to an action(genrep). The button is associated with a rich:message tag.

When a report type is selected and submitted, genrep() checks the database to see if there is any data, if none exists it instantiates a facesmessage, sets summary & detail to "No data" and adds it to the submit button via the addmessage method of facescontext.

When user submits another query that has data, genrep() gets the response stream from the facescontext, sets the contentype to "application/vnd.ms-excel" and writes data to it. Closes & flushs the stream and calls responsecomplete(). Except now I still see the 'no data' message next to the button from the previous no data query.

Thanks.


When user submits another query that has data, genrep() gets the response stream from the facescontext, sets the contentype to "application/vnd.ms-excel" and writes data to it. Closes & flushs the stream and calls responsecomplete(). Except now I still see the 'no data' message next to the button from the previous no data query.

So, you're providing a file download, but you're expecting the current page to refresh as well. That's not possible due to the nature of HTTP. You cannot send two responses back on a single request (one for the file download and another one for the new page). Best what you can do is to let the client send two requests or to hide the message using a line of JavaScript in the onclick attribute. The latter is more suitable in this particular case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜