You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by praveen kulkarni <jo...@yahoo.co.in> on 2004/06/02 17:51:21 UTC

How to display error msgs in a pop up window

Hi all,
 
Sub: How can i get error messages in a pop up window by using STRUTS
 
I am using Struts and i want to handle all validation error messages in a new popup window.
 
Consider Login form with loginID and password as form fields. I want to check mandatory status at the server side, for this i will put validate method in the FormBean. FormBean will create Error Object sends back to Login Page. I've to handle this error object in a new popup window instead of displaying in the Login page.
 
bye
PAK

Yahoo! India Matrimony: Find your partner online.

Re: How to display error msgs in a pop up window

Posted by Brad Balmer <bb...@peapod.com>.
Instead of using a pop-up I use a <div> block to format my messages. 

Inside my <logic:messagesPresent> I have my <div> block that will 
display any type of message or error that I want.  I then inlude a way 
to click on a close link which simply sets the <div> to be hidden and 
moves it off the page.

This is a non-javascript way of displaying errors or messages that also 
looks really nice.

To be nice I have included my showMessages.jsp page that I simply 
include at the top of each page.


<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic" %>
<logic:messagesPresent>
    <div id="messageId" class="displayMessages">
        <table width="500" height="120" border="3" align="center" 
cellpadding=3 cellspacing=0 bgcolor="white">
            <tr valign="top" align="center">
                <td align="center">
                    <table width="486">
                        <tr>
                            <td align="center" 
width="436"><u><b><i><font size="5" 
color="#0000FF">Messages</font></i></b></u></td>
                            <td width="40" align="center" 
valign="top"><font size="2" color="blue" style="cursor: pointer;"><u 
onClick="hideMessages('messageId')">Close</u></font></td>
                        </tr>                       
                        <tr>
                            <td colspan="2" width="480">
                               
                                    <font color="red"><html:errors/></font>
                                    <html:messages property="Exception" 
id="exception" >
                                        <font color="red"><bean:write 
name="exception"/></font><br>
                                    </html:messages>
                                    <html:messages property="Status" 
id="msg" >
                                        <font color="green"><bean:write 
name="msg"/></font><br>
                                    </html:messages>
                                 
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
</logic:messagesPresent>
<logic:messagesPresent message="true">
    <div id="messageId" class="displayMessages">
        <table width="500" height="120" border="3" align="center" 
cellpadding=3 cellspacing=0 bgcolor="white">
            <tr valign="top" align="center">
                <td align="center">
                    <table width="486">
                        <tr>
                            <td align="center" 
width="436"><u><b><i><font size="5" 
color="#0000FF">Messages</font></i></b></u></td>
                            <td width="40" align="center" 
valign="top"><font size="2" color="blue" style="cursor: pointer;"><u 
onClick="hideMessages('messageId')">Close</u></font></td>
                        </tr>                       
                        <tr>
                            <td colspan="2" width="480">
           
                                    <html:messages property="Exception" 
id="exception" message="true">
                                        <font color="red"><bean:write 
name="exception"/></font><br>
                                    </html:messages>
                                    <html:messages property="Status" 
id="msg" message="true">
                                        <font color="green"><bean:write 
name="msg"/></font><br>
                                    </html:messages>

                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
</logic:messagesPresent>





praveen kulkarni wrote:

>Hi all,
> 
>Sub: How can i get error messages in a pop up window by using STRUTS
> 
>I am using Struts and i want to handle all validation error messages in a new popup window.
> 
>Consider Login form with loginID and password as form fields. I want to check mandatory status at the server side, for this i will put validate method in the FormBean. FormBean will create Error Object sends back to Login Page. I've to handle this error object in a new popup window instead of displaying in the Login page.
> 
>bye
>PAK
>
>Yahoo! India Matrimony: Find your partner online.
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org