Foren

Liferay 6.2 - Getting Blank Error Alert when using SessionErrors

Zak Thompson, geändert vor 6 Jahren.

Liferay 6.2 - Getting Blank Error Alert when using SessionErrors

Junior Member Beiträge: 70 Beitrittsdatum: 13.06.16 Neueste Beiträge
I'm running into an issue with portlet development in 6.2, where using session errors is adding a blank 'alert alert-error' div to the page.

Relevant code:

In my portlet process action (I'm getting a spreadsheet from the user and using the data for a process, the segment below runs if validation on the spreadsheet fails):


if (!valid){
    session.setAttribute("successful", false);
    SessionErrors.add(request, "validation-error");
    response.setRenderParameter("mvcPath", "/html/archiveweb/results.jsp");
    return;
}


the results.jsp code (message with the key 'csv-validation-error-msg' exists in Language.properties)

<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<portlet:defineobjects />
&lt;%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %&gt;
<liferay-theme:defineobjects />

<liferay-ui:error key="validation-error" message="csv-validation-error-msg" />

<portlet:renderurl var="resetUrl">
	<portlet:param name="mvcPath" value="/html/archiveweb/view.jsp" />
</portlet:renderurl>


<c:if test="${successful}">
	&lt;--JSTL to render info from the report here--&gt;
</c:if>


<div style="text-align: center">
	<aui:button type="submit" value="Run the process with a new spreadsheet" onClick="<%=resetUrl%>" cssClass="archiveButton" />
</div>



the issue that I'm getting is that in addition to the alert that I want to be displayed when a validation error occurs, I'm also getting a blank error alert above it.

Here's an excerpt from the HTML generated on the page:

<div class="alert alert-error"> </div> 
<div class="alert alert-error"> The CSV could not be successfully validated </div>


If anyone has any idea where this empty error alert is coming from, I would appreciate the insight.

EDIT: Adding some additional logging and now I'm thoroughly confused.

I added the following scriptlet to the top of the JSP:


&lt;%
	final Set<string> errors = SessionErrors.keySet(renderRequest);

	System.out.println("STARTING ERROR LOG!!!");
	System.out.println(SessionErrors.size(renderRequest));
	for (final String error : errors) {
		System.out.println(error);
	}
%&gt;
</string>


Output:
STARTING ERROR LOG!!!
1
validation-error

So clearly there is only one error in the log. I have no idea where this ghost error message is coming from
thumbnail
Andrew Jardine, geändert vor 6 Jahren.

RE: Liferay 6.2 - Getting Blank Error Alert when using SessionErrors

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
Hey Zak,

When I am using this taglib, I always use the key value from the language bundle for both the key and message attributes. So if your key is csv-validation-error-msg then can you try this line in your jsp --

<liferay-ui:error key="csv-validation-error-msg" message="csv-validation-error-msg" />


That pretty well always works for me.