/** * Called when the validated markup does not contain any errors. * * @param responseBuffer * the validated response markup * @param report * the validation report */ protected void onValidMarkup(AppendingStringBuffer responseBuffer, ValidationReport report) { IRequestablePage responsePage = getResponsePage(); DocType doctype = getDocType(responseBuffer); log.info("Markup for {} is valid {}", responsePage != null ? responsePage.getClass().getName() : "<unable to determine page class>", doctype.name()); String head = report.getHeadMarkup(); String body = report.getBodyMarkup(); int indexOfHeadClose = responseBuffer.lastIndexOf("</head>"); responseBuffer.insert(indexOfHeadClose, head); int indexOfBodyClose = responseBuffer.lastIndexOf("</body>"); responseBuffer.insert(indexOfBodyClose, body); }
public AppendingStringBuffer filter(AppendingStringBuffer responseBuffer) { IRequestablePage responsePage = getResponsePage(); if (responsePage != null && !(responsePage instanceof Page) || RequestCycle.get().find(AjaxRequestTarget.class) != null) { return responseBuffer; } DocType docType = getDocType(responseBuffer); if (docType == null) { setMetaData("Unknown doctype"); onUnknownDocType(responseBuffer); return responseBuffer; } try { ValidationReport report = validateMarkup(responseBuffer.toString(), docType); if (report.isValid()) { setMetaData("Markup is valid " + docType); onValidMarkup(responseBuffer, report); } else { setMetaData("Markup is invalid " + docType); onInvalidMarkup(responseBuffer, report); } } catch (Exception e) { log.error(e.toString(), e); } return responseBuffer; }