File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Multiple windows - clearing html:errors on parent window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Multiple windows - clearing html:errors on parent window" Watch "Multiple windows - clearing html:errors on parent window" New topic

Multiple windows - clearing html:errors on parent window

Jane Shields

Joined: Jun 06, 2006
Posts: 1

I have a JSP report search page which displays error messages for missing mandatory fields using html:errors properties.

If a user gets these errors then performs a successful search, they get an excel results page in a new window with the content type for the page as "application/".

The problem is that the 'parent' report search page still displays the errors. The action class sends it's response to the new window so the original page is not refreshed. I need to display the search criteria on the original page but remove the errors when a user performs a successful search.

I cannot see how to do this.
1. I thought of calling a JavaScript function when the getReport button was pressed to clear the errors. But the html:errors are Struts components so cant be altered on the client side....

2. From the server side, the action class can only send one response which we currently send to the results window. I cannot refresh/rebuild the search page AND forward to the results page.

If I'm missing something obvious, please help......
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You can remove the messages with javascript by using the the Document Object Model (DOM). There is a removeChild() method that you can execute from any node. All you have to do is get a reference to the part of the page that is showing the message (table? Unordered list?), find it's immediate parent, and execute the removeChild() method.

Another way to do it would be to hide the message without actually removing it. If you're not familiar with the DOM, here's a link that will get you started:
[ June 08, 2006: Message edited by: Merrill Higginson ]

Consultant, Sima Solutions
I agree. Here's the link:
subject: Multiple windows - clearing html:errors on parent window
It's not a secret anymore!