Fork me on GitHub

Site messages

Site messages (or user messages) can be displayed on Lutece site (front office). Theses messages can be used when :

  • User want to execute an unhautorized action (restricted area),
  • an application error must be reported to user,
  • a confirmation message must be displayed.
Site message details :
  • title,
  • message
  • arguments associated with message,
  • url validation,
  • url validation target (défault : "_self"),
  • type of message (information, questionn, error, warning, confirmation, stop),
  • Cancel button (true of false).

Content types

Site messages can be used in many content types :


SiteMessageService provide a method setMessage() to display site messages. To display Site message, an exception SiteMessageException is thrown. Example to use setMessage() method :

SiteMessageService.setMessage( request, PROPERTY_ACCESS_DENIED_ERROR_MESSAGE, null,
PROPERTY_ACCESS_DENIED_ERROR_MESSAGE and PROPERTY_ACCESS_DENIED_TITLE_MESSAGE Constants are the internationalization strings of message and title message.

mylutece database module now using this service. It can be used in example.

Using service in filter

SiteMessageService can be used in filters. However, they have to catch themselves exception and forward to Portal.jsp. UploadFilter filter provide an implementation example :

	SiteMessageService.setMessage( httpRequest, PROPERTY_MESSAGE_FILE_SIZE_LIMIT_EXCEEDED,
		new String[] { _nRequestSizeMax }, PROPERTY_TITLE_FILE_SIZE_LIMIT_EXCEEDED, null,
		"", SiteMessage.TYPE_STOP );
catch ( SiteMessageException lme )
	request.getRequestDispatcher( "/" + 
		AppPathService.getPortalUrl(  ) ).forward( request, response );