Add error report for fields on new map.
Display error messages
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
<%@ page session="false" contentType="text/html;charset=UTF-8" %>
|
||||
|
||||
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
|
||||
<%--<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>--%>
|
||||
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<%
|
||||
|
@@ -161,10 +161,14 @@
|
||||
$("#buttons .newMap").button({
|
||||
icons: { primary: "ui-icon-circle-plus" }
|
||||
}).click(function() {
|
||||
// Clean previous dialog content ...
|
||||
$("#new-dialog-modal div[id='errorMessage']").text("").removeClass("ui-state-highlight");
|
||||
|
||||
$("#new-dialog-modal").dialog({
|
||||
modal: true,
|
||||
buttons: {
|
||||
"Create": function() {
|
||||
|
||||
var formData = {};
|
||||
$('#new-dialog-modal input').each(function(index, elem) {
|
||||
formData[elem.name] = elem.value;
|
||||
@@ -180,12 +184,37 @@
|
||||
var mapId = jqXHR.getResponseHeader("ResourceId");
|
||||
window.location = "c/editor.htm?action=open&mapId=" + mapId;
|
||||
},
|
||||
error: function() {
|
||||
alert("Unexpected error removing maps. Refresh before continue.");
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
if (jqXHR.status == 400) {
|
||||
var errors = JSON.parse(jqXHR.responseText);
|
||||
// Clean previous marks ....
|
||||
$('#new-dialog-modal input').each(function(index, elem) {
|
||||
$(elem).removeClass("ui-state-error");
|
||||
});
|
||||
|
||||
// Mark fields with errors ...
|
||||
var fieldErrors = errors.fieldErrors;
|
||||
if (fieldErrors) {
|
||||
for (var fieldName in fieldErrors) {
|
||||
// Mark the field ...
|
||||
var message = fieldErrors[fieldName];
|
||||
var inputField = $("#new-dialog-modal input[name='" + fieldName + "']");
|
||||
$(inputField).addClass("ui-state-error");
|
||||
|
||||
|
||||
$("#new-dialog-modal div[id='errorMessage']").text(message).addClass("ui-state-highlight");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
alert("Unexpected error removing maps. Refresh before continue.");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
Cancel: function() {
|
||||
Cancel:function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}
|
||||
@@ -221,7 +250,8 @@
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
;
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -241,7 +271,9 @@
|
||||
<div id="delete-dialog-modal" title="Delete maps" style="display: none">
|
||||
<p>Are you sure you want to delete maps <span></span> ?</p>
|
||||
</div>
|
||||
<div id="new-dialog-modal" title="New" style="display: none">
|
||||
<div id="new-dialog-modal" title="Add new map" style="display: none">
|
||||
<div id="errorMessage"></div>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td class="formLabel">
|
||||
@@ -281,7 +313,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="map-table">
|
||||
<table cellpadding="0" cellspacing="0" border="0" class="display" id="mindmapListTable">
|
||||
<table class="display" id="mindmapListTable">
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
@@ -1,49 +0,0 @@
|
||||
<%@ include file="/jsp/init.jsp" %>
|
||||
|
||||
<h1>
|
||||
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<form:form method="post" commandName="newMap">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="formLabel">
|
||||
<span class="fieldRequired">*</span>
|
||||
<spring:message code="NAME"/>
|
||||
:
|
||||
</td>
|
||||
<td>
|
||||
<form:input path="title" id="title" tabindex="1"/>
|
||||
<form:errors path="title" cssClass="errorMsg"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="formLabel">
|
||||
<spring:message code="DESCRIPTION"/>
|
||||
:
|
||||
</td>
|
||||
<td>
|
||||
<form:input path="description" id="description" tabindex="2"/>
|
||||
<form:errors path="description" cssClass="errorMsg"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<input type="submit" value="Accept" class="btn-primary">
|
||||
<c:choose>
|
||||
<c:when test="${!errorView}">
|
||||
<input type="button" value="<spring:message code="CANCEL"/>" class="btn-secondary"
|
||||
onclick="MOOdalBox.close();">
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<input type="button" value="<spring:message code="BACK"/>" class="btn-secondary"
|
||||
onclick="window.location='mymaps.htm'">
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form:form>
|
||||
</div>
|
@@ -1,11 +0,0 @@
|
||||
<%@ include file="/jsp/init.jsp" %>
|
||||
|
||||
<h1>
|
||||
<spring:message code="${requestScope.title}"/>
|
||||
</h1>
|
||||
|
||||
<p style="font-weight:bold;">
|
||||
<spring:message code="${requestScope.details}"/>
|
||||
</p>
|
||||
|
||||
<jsp:include page="/jsp/newMap.jsp"/>
|
@@ -23,10 +23,6 @@
|
||||
<link rel="stylesheet" type="text/css" href="../css/wisehome.css"/>
|
||||
<link rel="icon" href="${pageContext.request.contextPath}/images/favicon.ico" type="image/x-icon"/>
|
||||
<link rel="shortcut icon" href="${pageContext.request.contextPath}/images/favicon.ico" type="image/x-icon"/>
|
||||
<script type='text/javascript'
|
||||
src='https://ajax.googleapis.com/ajax/libs/mootools/1.3.2/mootools-yui-compressed.js'></script>
|
||||
<script type='text/javascript' src='../js/mootools-more.js'></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
Reference in New Issue
Block a user