Problem with ActionMessages and Frames

Discussions

Web tier: servlets, JSP, Web frameworks: Problem with ActionMessages and Frames

  1. Problem with ActionMessages and Frames (2 messages)

    Hi,

    I am facing a problem in my web application.
    My web application uses frames as specified below :
    ===========================
    <frameset rows="93,*,395,*,37" framespacing="0" frameborder="NO" border="0" bordercolor="#CCCCCC">
    <frame name="topFrame" scrolling="NO" noresize src="TopLogin.do" >
    <frame name="blank1Frame" src="Blank.do" scrolling="NO">
    <frame name="mainFrame" src="MainLogin.do" scrolling="NO" noresize>
    <frame name="blankFrame" src="Blank.do" scrolling="NO">
    <frame name="bottomFrame" scrolling="NO" noresize src="Footer.do">
    </frameset>
    ===========================

    This is the login page and is displayed using the ForwardAction Index.do.

    From my LoginAction I check if the user is authenticated or not and forward display the index page if not authenticated else the welcome page.
    The code in action reads :

    =================
    if(!authenticated){
    ActionMessage l_actionMessage = new ActionMessage("error.userdoesnotexist");
    ActionMessages l_actionMessages = new ActionMessages();
    l_actionMessages.add("userdoesnotexist", l_actionMessage);
    saveMessages(p_request, l_actionMessages);
    l_forward = "failure";
    }
    =========
    where failure is a ActionForward which points to Index.do.

    My problem is I want to display the authentication failure message in the mainframe i.e. 3rd frame in the frameset of which the page is composed.
    I tried printing the request contents on the login.jsp (Index.do) , it shows me

    org.apache.struts.action.ACTION_MESSAGE:{userdoesnotexist=[error.userdoesnotexist[]]}

    But this is not available in the MainLogin.do.

    Would appreciate a quick help.
    Thanks in advance,
    Regards,
    Amol

    Threaded Messages (2)

  2. Use Tiles Instead?[ Go to top ]

    If all you are doing is using frames to help with page region re-use then look at using tiles instead:
    http://struts.apache.org/userGuide/building_view.html#Tiles
  3. Request and Session[ Go to top ]

    You're storing you ActionMessages in the request to the frame loading JSP and your frame loading JSP makes new requests to load its parts, causing the original request to be lost along with your ActionMessages.

    Try saving your ActionMessages in the session instead. I know you can do this with more recent Struts releases using the saveMessages(session, messages).

    But definitely take a look at tiles, too...it's better than frames.