Archive for February, 2008

Letting end-user confirm destructive actions

Thursday, February 21st, 2008

Aranea 1.1 standard component chain enriches Environment with a context called ConfirmationContext. This can be used for executing some code conditionally, depending on user actions. Context interface is simple and consists of following methods:

JAVA:
  1. public interface ConfirmationContext {
  2.   void confirm(Closure onConfirmClosure, String message);
  3.   String getConfirmationMessage();
  4. }

When confirmation is registered (with confirm() method), rendering mechanism will present end-user with the browser standard message box and ask for confirmation of requested action. Depending on users choice, action encapsulated in onConfirmClosure either will get executed or not.

Combined with TransitionHandler, confirmation could be asked whenever the user performs navigation that would make active flow unreachable and flow contains data that has not yet been saved.

JAVA:
  1. getFlowCtx().setTransitionHandler(
  2.   new CancelConfirmingTransitionHandler(
  3.      new ShouldConfirmOnUnsavedData(),
  4.      "Some data not saved yet. Continue anyway?"
  5.   )
  6. );

Here CancelConfirmingTransitionHandler registers the confirmation whenever FlowContext.cancel() is called from active flow and Predicate ShouldConfirmOnUnsavedData evaluates to true. Only after user confirms the navigation event will flow transition actually be performed.

ConfirmationContext and TransitionHandlers together are a reliable and convenient way of preventing end-users shooting themselves in the foot :).

Aranea-MVC 1.1-RC1

Thursday, February 7th, 2008

And ... the 1.1-RC1 is here sooner than expected :) Mainly this is due to pushing back-button support into the 1.2 release cycle. It will still be done very soon (within this February). This release contains fixes for bugs which were reported since last milestone and documentation updates.

Enjoy!