public abstract class AbstractValidatorServlet extends AbstractJsonResponseServlet
@SlingServlet(resourceTypes = "aem-library/components/content/example", selectors = "validator", extensions = "json", methods = "GET")The "resourceTypes" annotation will need to be updated to match the resource type of the component being validated. The component dialog.xml can call the the validator for a given dialog field using the following function:
<name jcr:primaryType="cq:Widget" fieldLabel="Name" name="./name" xtype="textfield"
validator="function(value) {
return AEM.Library.Utilities.Dialog.validateField(this, value, 'Name is invalid');
}" />
DEFAULT_DATE_FORMAT
Constructor and Description |
---|
AbstractValidatorServlet() |
Modifier and Type | Method and Description |
---|---|
protected void |
doGet(org.apache.sling.api.SlingHttpServletRequest request,
org.apache.sling.api.SlingHttpServletResponse response) |
protected abstract boolean |
isValid(org.apache.sling.api.SlingHttpServletRequest request,
String path,
String value)
Validate the given value for this request and path.
|
writeJsonResponse, writeJsonResponse, writeJsonResponse, writeJsonResponse
doDelete, doPost, doPut, getAllowedRequestMethods, isMethodValid, mayService
doGeneric, doHead, doOptions, doTrace, getServletInfo, handleMethodNotImplemented, service, service
protected final void doGet(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response) throws javax.servlet.ServletException, IOException
doGet
in class org.apache.sling.api.servlets.SlingSafeMethodsServlet
javax.servlet.ServletException
IOException
protected abstract boolean isValid(org.apache.sling.api.SlingHttpServletRequest request, String path, String value)
request
- servlet requestpath
- path to current component being validatedvalue
- input value to validateCopyright © 2019 ICF Next. All rights reserved.