-
Notifications
You must be signed in to change notification settings - Fork 77
Success message posting
After a user saves a entered data openELIS will display a "Success" message at the top of the page. This explains how the feature is added to a page
##Background
- The Tile Page
actionSuccess.jsp
actually displays the message. This page also contains a javascript methodshowSuccessMessage( boolean show );
- The
BaseAction.java
class looks for a URL parameterforward=success
and places the attributesuccess=true
in the request. - In the standard footer pages, e.g.
saveCancelFooterButtons.jsp
checks for the abovesuccess
attribute in the request and calls theshowSuccessMessage( true );
== What the developer needs to do==
=== Include the message tile===
In the struts tile definition file, e.g. {{{tile-globalOpenELIS.xml}}}, the message tile can be included in any tile definition by placing it in the {{{preSelectionHeader}}} (we weren't using this section for anything else and it's in the right place on the standard page). {{{ ... }}}
=== Tell the page to display the message=== To trigger the {{{BaseAction}}} to find the URL parameter and thus get the included tile to display the success message you have two choices.
-
In the struts file, i.e. {{{struts-globalOpenElis.xml}}}, in a {{{forward}}} element add an extra URL parameter to any other action forwarding successfully to the page; see below. This method requires very little extra declaration. {{{ }}}
-
In your Action class where you would normally do {{{return mapping.findForward(forward);}}} use instead the {{{BaseAction.getForwardWithParameter}}} method {{{return getForwardWithParameters(mapping.findForward(forward), params );}}} with a parameter of {{{"forward"}}} with a value of {{{"success"}}}. This method is particularly useful when one action forwards to another action and there is no page URL onto which to append the extra parameter.
=== Clear the message when it's no longer needed.===
To clear the message whenever the user starts to type add a call to showMessageSuccess whenever something new happens. For example, if you always call makeDirty() in every fields onChange, {{{onChange="...' makeDirty()"}}}, your {{{makeDirty()}}} method might look like the following
{{{ function /void/ makeDirty(){ dirty = true; // do other work if( typeof(showSuccessMessage) != 'undefinded' ){ showSuccessMessage(false); //refers to last save } } }}}