Message Bar


This extension has two purposes. The first one is the ULCMessageBar component. This is a component which can show messages in two ways. One way is to show the message as long as you do not click on it, or on the other way, the message will be shown only for a predefined time.


The second purpose of this extension is the ULCMessageDataType. This DataType is a decorater for IDataTypes, which associates a datatype with a message. If the validation fails, the message is shown on the IMessageDisplayHandler permanetly or temporary without server round trip.


How to use


You can use it like a ULCLabel and you get the functionality of hiding the message with a timer or with a mouse-click.

IMessageDisplayHandler messageBar = new ULCMessageBar(3000);
messageBar.showMessage("This message is visible until you click it away!", false);
// or
messageBar.showMessage("This message is shown for 3 seconds or you click it away!", true);

Moreover you can configure the message bar such that a default message is shown when no other message should be displayed. (If not set, the default message is null.)

messageBar.setDefaultMessage("The default message");

You can also configure the message bar such that the last non-default message automatically appears, when the user enters the message bar area with the mouse.



You can use it like the existing DataTypes (ULCStrinDataType, ULCDateDataType, ...). ULCMessageDataType decorates an existing DataType and shows a message on a IMessageDisplayHandler, if the validation fails without a server round trip.

IMessageDisplayHandler messageBar = new ULCMessageBar(2000);
ULCTextField dateTextField = new ULCTextField(10);
IDataType dataType = new ULCMessageDataType(new ULCDateDataType(), messageBar, "Must be date.");

You can configure the message data type such that a beep occurs, whenever the validation of the underlying data type changes from valid to invalid. (By default beeping is disabled.)


How it is implemented


The ULCMessageBar is a simple subclass of ULCLabel, which implements the interface IMessageDisplayHandler. All the communication and client side handling of hiding a message is done in the class ULCMessageDisplayManager. This has the benefit, that it should be easy to implement a new IMessageDisplayHandler. Important is the implementation on server side, where you have first to register your new component to the ULCMessageDisplayManager and afterwards, delegating in each method to the ULCMessageDisplayManager. The client side implementation has only to implement the two methods.

// server side implementation

public class YourServerSideComponent extends (ULCProxy or some subclass of it) implements {

public YourServerSideComponent(int displayTime) { ULCMessageDisplayManager.register(this); // don't forget to register your component! setDisplayTime(displayTime); }

public void setDisplayTime(int displayTime) { if (displayTime < 0) { throw new IllegalArgumentException("Invalid display time: " + displayTime); } ULCMessageDisplayManager.setDisplayTime(this, displayTime); }

public void showMessage(String message, boolean temporary) { ULCMessageDisplayManager.showMessage(this, message, temporary); }

public void resetMessage() { ULCMessageDisplayManager.resetMessage(this); }

protected String typeString() { return "YourClientSideComponent"; } }

//client side implementation

public class YourClientSideComponent implements {

public void showMessage(String message) { // your implementation; }

public void clearMessage() { // your implementation; } }


This is an implementation of IDataType and decorates another IDataType with the functionality of displaying a message if the validation fails. On client side, the UIMessageDisplayManager is called when the validation fails.

private void showMessage(IMessageDisplayHandler messageDisplayHandler, String message, boolean temporary) {

    UIMessageDisplayManager instance = UIMessageDisplayManager.getInstance(getSession());
    instance.showMessage(messageDisplayHandler, message, temporary);