jp.terasoluna.fw.web.struts.taglib
Class MessagesPopupTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by jp.terasoluna.fw.web.struts.taglib.MessagesPopupTag
All Implemented Interfaces:
java.io.Serializable, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

public class MessagesPopupTag
extends javax.servlet.jsp.tagext.TagSupport

When 1 user operates the screen for different use cases and error message is being poped-up at the same time, error message information for each use case gets mixed up in session and get displayed.
Mixing up of pop-up errors generated on screen can be avoided by combining this tag with <ts:errors>tag and <ts:messages> tag.
MessagesPopupTag stores the error message information, which is registered as attributes of "Request", in the session.

Pop-up screen is opened by linking MessagesPopupTag with <ts:body> tag. MessagesPopupTag is always used with <ts:body> tag. MessagesPopupTag should be specified before <ts:body> tag.

MessagesPopupTag adds the script to onLoad of JavaScript.
In order to display the pop-up screen that displays error message information, follow the below procedure. Please note that this tag should be placed on the transition screen after error messages are generated and not on the screen before error messages are generated.

  1. Result screen, corresponding to the input, is returned.
  2. Pop-up screen gets opened on the onLoad event of the result screen.
  3. Request to displays error message information is sent to server.

MessagesPopupTag is overwritten with the original onLoad event process script . This script is generated by <ts:body> tag. In JSP, when there is a onLoad tag before MessagesPopupTag, the script in onLoad becomes valid when there is no error. When there is a error, the script is overwritten by the MessagesPopupTag settings and pop-up screen is displayed. This screen displays the error message.

Attribute supported by tag

In MessagesPopupTag, following attributes are supported.

Attribute name Default value Required Execution time format Overview
popup - true true URL which is displayed on pop-up screen. It is the first argument of window.open() of JavaScript.
title popup false true Title of pop-up screen that displays error.
param - false true Parameter string when pop-up screen is opened in JavaScript.
paramType - false true It is the resource key when pop-up screen is opened in JavaScript and parameter string is fetched from ApplicationResources file.
paramFunc - false true JavaScript function name that fetches parameter string when pop-up screen is opened in JavaScript.
windowId - false true JavaScript variable name that retains the pop-up screen which is opened.


Scripting variable of custom tag

There is no scripting variable set by this tag.


How to use

 <ts:messagesPopup popup="/popup/errors.do" />
   ...
 <ts:body ...>
 

See Also:
BodyTag, Serialized Form

Field Summary
private static java.lang.String DEFAULT_TITLE
          Default title. Value is popup.
static java.lang.String ON_LOAD_KEY
          Key when onLoad process is stored in "request" attribute.
private  java.lang.String param
          Parameter string when pop-up screen is opened in JavaScript.
private  java.lang.String paramFunc
          JavaScript function name that fetches parameter string when pop-up screen is opened in JavaScript.
private  java.lang.String popup
          URL which is displayed on pop-up screen. It does not include context path.
static java.lang.String POPUP_ERROR_KEY
          Error information key which is passed through "request" parameter at the time of pop-up.
static java.lang.String POPUP_MESSAGE_KEY
          Message information key which is passed through "request" parameter at the time of pop-up.
private static long serialVersionUID
          Serial version ID
private  java.lang.String title
          Title of pop-up screen that displays error information and message information.
private  java.lang.String windowId
          JavaScript variable name that retains the pop-up screen which is opened.
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
MessagesPopupTag()
           
 
Method Summary
 int doEndTag()
          Method which is called at the time of terminating tag evaluation.
 int doStartTag()
          Method which is called at the time of starting tag evaluation.
private  java.lang.String getOnLoadScript(javax.servlet.http.HttpServletRequest req, java.lang.String errorKey, java.lang.String messageKey)
          Generates script for opening thw window which is specified in onLoad attribute of <body> tag.
private  java.lang.String getRequestParameterKey(java.lang.String errorKey, java.lang.String messageKey)
          Creates query string of "Request" parameter based on the error message information key which is stored in session.
 void release()
          Process at the time of releasing the tag handler.
 void setParam(java.lang.String value)
          Sets parameter string when pop-up screen is opened in JavaScript.
 void setParamFunc(java.lang.String value)
          Sets return value of JavaScript function . This JavaScript function is specified as parameter string when pop-up screen is opened in JavaScript.
 void setParamType(java.lang.String value)
          Fetches parameter string from ApplicationResources file when pop-up screen is opened in JavaScript and sets the string.
 void setPopup(java.lang.String value)
          Sets URL which is displayed on pop-up screen.
 void setTitle(java.lang.String value)
          Sets title of pop-up screen that displays error.
 void setWindowId(java.lang.String value)
          Sets JavaScript variable name that retains the pop-up screen which is opened.
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Serial version ID

See Also:
Constant Field Values

ON_LOAD_KEY

public static final java.lang.String ON_LOAD_KEY
Key when onLoad process is stored in "Request" attribute.

See Also:
Constant Field Values

POPUP_ERROR_KEY

public static final java.lang.String POPUP_ERROR_KEY
Error information key which is passed by "Request" parameter at the time of pop-up.

See Also:
Constant Field Values

POPUP_MESSAGE_KEY

public static final java.lang.String POPUP_MESSAGE_KEY
Message information key which is passed by "request" parameter at the time of pop-up.

See Also:
Constant Field Values

DEFAULT_TITLE

private static final java.lang.String DEFAULT_TITLE
Default title. Value is popup.

See Also:
Constant Field Values

popup

private java.lang.String popup
URL which is displayed on pop-up screen. It does not include context path.


title

private java.lang.String title
Title of pop-up screen that displays error information and message information.


param

private java.lang.String param
Paramater string when pop-up screen is opened in JavaScript.


paramFunc

private java.lang.String paramFunc
JavaScript function name that fetches parameter string when pop-up screen is opened in JavaScript.


windowId

private java.lang.String windowId
JavaScript variable name that retains pop-up screen which is opened up.

Constructor Detail

MessagesPopupTag

public MessagesPopupTag()
Method Detail

setPopup

public void setPopup(java.lang.String value)
Sets URL which is displayed on pop-up screen.

Parameters:
value - URL which is displayed on pop-up screen.

setTitle

public void setTitle(java.lang.String value)
Sets title of pop-up screen that displays error.

Parameters:
value - Title

setParam

public void setParam(java.lang.String value)
Sets parameter string when pop-up screen is opened in JavaScript.

Parameters:
value - Parameter

setParamType

public void setParamType(java.lang.String value)
Fetches the parameter string from ApplicationResources file when pop-up screen is opened in JavaScript and sets the string.

Parameters:
value - Parameter

setParamFunc

public void setParamFunc(java.lang.String value)
Sets return value of JavaScript function. This function is specified as parameter string when pop-up screen is opened in JavaScript.

Parameters:
value - Parameter

setWindowId

public void setWindowId(java.lang.String value)
Sets JavaScript variable name that retains the pop-up screen which is opened.

Parameters:
value - Variable name

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Method which is called at the time of starting tag evaluation.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.TagSupport
Returns:
Process control instructions. Always EVAL_BODY_INCLUDE
Throws:
javax.servlet.jsp.JspException - JSP exception

getOnLoadScript

private java.lang.String getOnLoadScript(javax.servlet.http.HttpServletRequest req,
                                         java.lang.String errorKey,
                                         java.lang.String messageKey)
Generates script for opening the window which is specified in onLoad attribute of <body> tag.

Parameters:
req - HTTP request
errorKey - Error information key
messageKey - Message information key
Returns:
Script to open the window

getRequestParameterKey

private java.lang.String getRequestParameterKey(java.lang.String errorKey,
                                                java.lang.String messageKey)
Creates query string of "request" parameter based on the error message information key which is stored in the session.

Parameters:
errorKey - Error information key
messageKey - Message information key
Returns:
Query string which is sent as request parameter

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Method which is called at the time of terminating tag evaluation.

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.TagSupport
Returns:
Process control instructions. Always EVAL_PAGE
Throws:
javax.servlet.jsp.JspException - JSP exception

release

public void release()
Process at the time of releasing tag handler.

Specified by:
release in interface javax.servlet.jsp.tagext.Tag
Overrides:
release in class javax.servlet.jsp.tagext.TagSupport