Frage

If I try to upload some file which is exceeding on the limit size.. There are no error message shown on the screen but however, I did find an error message on the logs saying:

 03:24:20,890 ERROR [UploadServletRequestImpl:101] org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (220546593) exceeds the configured maximum (104857600)
org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (220546593) exceeds the configured maximum (104857600)

I want to specifically show an error message on my screen saying: "You've reached the maximum size of 10mb."

Thanks.

War es hilfreich?

Lösung

In you action class you will add your error key along with request object like below,

SessionErrors.add(actionRequest, "your-error");

In your JSP you will add:

<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<liferay-ui:error key="your-error" message="Your error message goes here!" />

Also it could be handled through exception class, With SessionErrors code like,

try {
    // ... Code which will throws the exception
} catch(SomeException se) {
    SessionErrors.add(actionRequest, se.getClass().getName());
}

In jsp

<liferay-ui:error exception="<%= SomeException.class %>" message="This is your Error" />

Reference link: http://www.liferay.com/community/wiki/-/wiki/Main/User+Feedback+-+Success+and+Error+Messages+in+Portlets

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top