Skip to content

Success message posting

Paul Schwartz edited this page Jun 2, 2015 · 3 revisions

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 method showSuccessMessage( boolean show );
  • The BaseAction.java class looks for a URL parameter forward=success and places the attribute success=true in the request.
  • In the standard footer pages, e.g. saveCancelFooterButtons.jsp checks for the above success attribute in the request and calls the showSuccessMessage( 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 } } }}}

Clone this wiki locally