0

I have a login modal. The modal(bootstrap) form is a part of header.jsp which gets included in every JSP. How do I get action error messages back to my modal if user enters wrong username/password?

Struts.xml

<action name="authenticate" method="login"
       class="app.resumerepo.in.action.LoginAction">
    <interceptor-ref name="loginCheck" />
    <result name="success" type="redirect">myaccount.action</result>
    <result name="input"> </result>
    <result name="error">/jsp/common/error.jsp</result>
</action>

for the result "input" what I should mention so that I get action error messages on to Login modal?

Siguza
  • 21,155
  • 6
  • 52
  • 89
user1493834
  • 756
  • 4
  • 11
  • 25

2 Answers2

1
  1. Ensure your loginCheck is an Interceptor Stack, and not a single Interceptor. In the latter case, create a custom Interceptor Stack with your loginCheck Interceptor inside, or declare both your Interceptor and the defaultStack like this:

    <action name="authenticate" method="login"
           class="app.resumerepo.in.action.LoginAction">
        <interceptor-ref name="loginCheck"   />
        <interceptor-ref name="defaultStack" />
        ...
    
  2. In your code it is not shown how you landed on the login page; btw, to make it work as you are asking, just configure the input result to return the JSP page you are coming from, eg:

    <result name="input">login.jsp</result>
    

    Take a look at this example that may help.

Community
  • 1
  • 1
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
0

I am going to correct the interceptor part and on login fail , I redirected to a login_error.jsp where I am calling the same modal. It works as expected.

                    <%@page session="false"%>
                    <%@taglib uri="/struts-tags" prefix="s"%>
                    <%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
                    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
                    <html>
                    <head>
                    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
                    <title>Insert title here</title>

                    </head>
                    <body style="background-color:#FFF;">
                       <script type="text/javascript">
                        $('#myModal').modal('show'); 
                       </script>

                    </body>
                    </html> 
user1493834
  • 756
  • 4
  • 11
  • 25