twitter-bootstrapjspstruts2struts2-jquerystruts-action

How to get struts2 action messages on to Modal


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?


Solution

    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.