Example usage for org.springframework.web.bind WebDataBinder setAllowedFields

List of usage examples for org.springframework.web.bind WebDataBinder setAllowedFields

Introduction

In this page you can find the example usage for org.springframework.web.bind WebDataBinder setAllowedFields.

Prototype

public void setAllowedFields(@Nullable String... allowedFields) 

Source Link

Document

Register fields that should be allowed for binding.

Usage

From source file:com.springinpractice.ch11.web.controller.AbstractCrudController.java

/**
 * @param binder binder//from  ww w  .j  a  v a2  s. co  m
 */
@InitBinder(MK_FORM_DATA)
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
    binder.setAllowedFields(getAllowedFields());
}

From source file:org.jasig.portlet.announcements.controller.AdminAnnouncementController.java

@InitBinder("announcement")
public void initBinder(WebDataBinder binder) {
    SimpleDateFormat dateFormat = new SimpleDateFormat(customDateFormat);
    dateFormat.setLenient(false);//from   w  w w  . j a v a  2s  . com
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
    binder.registerCustomEditor(Topic.class, topicEditor);
    binder.setAllowedFields(new String[] { "id", "created", "author", "title", "abstractText", "message",
            "link", "startDisplay", "endDisplay", "parent", "action", "attachments" });
}

From source file:com.denimgroup.threadfix.webapp.controller.SystemSettingsController.java

@InitBinder
public void initBinder(WebDataBinder dataBinder) {
    String[] reports = { "dashboardTopLeft.id", "dashboardTopRight.id", "dashboardBottomLeft.id",
            "dashboardBottomRight.id", "applicationTopLeft.id", "applicationTopRight.id", "teamTopLeft.id",
            "teamTopRight.id", "fileUploadLocation", "deleteUploadedFiles", "csvExportFields[*]", "baseUrl",
            "closeVulnWhenNoScannersReport" };

    String[] otherSections = { "defaultRoleId", "globalGroupEnabled", "activeDirectoryBase",
            "activeDirectoryURL", "activeDirectoryUsername", "activeDirectoryCredentials", "proxyHost",
            "proxyPort", "proxyUsername", "proxyPassword", "shouldProxyVeracode", "shouldProxyQualys",
            "shouldProxyTFS", "shouldProxyBugzilla", "shouldProxyJira", "shouldProxyVersionOne",
            "shouldProxyHPQC", "shouldProxyWhiteHat", "shouldProxyTrustwaveHailstorm", "shouldProxyContrast",
            "shouldUseProxyCredentials", "sessionTimeout" };

    if (EnterpriseTest.isEnterprise()) {
        dataBinder.setAllowedFields(ArrayUtils.addAll(otherSections, reports));
    } else {/*w  ww.j  a v  a  2s . co  m*/
        dataBinder.setAllowedFields(reports);
    }

    dataBinder.registerCustomEditor(CSVExportField.class, "csvExportFields[*]",
            new CSVExportFieldEnumConverter(CSVExportField.class));
}

From source file:org.georchestra.console.ws.newaccount.NewAccountFormController.java

@InitBinder
public void initForm(WebDataBinder dataBinder) {
    dataBinder.setAllowedFields(new String[] { "firstName", "surname", "email", "phone", "org", "title",
            "description", "uid", "password", "confirmPassword", "createOrg", "orgName", "orgShortName",
            "orgAddress", "orgType", "orgCities", "recaptcha_response_field" });
}

From source file:org.georchestra.console.ws.passwordrecovery.NewPasswordFormController.java

@InitBinder
public void initForm(WebDataBinder dataBinder) {

    dataBinder.setAllowedFields(new String[] { "password", "confirmPassword" });
}

From source file:org.georchestra.console.ws.passwordrecovery.PasswordRecoveryFormController.java

@InitBinder
public void initForm(WebDataBinder dataBinder) {

    dataBinder.setAllowedFields(new String[] { "email", "recaptcha_response_field" });
}

From source file:org.owasp.dependencytrack.controller.ApplicationController.java

/**
 * Limits what fields can be automatically bound.
 * //from w  w  w . ja v  a2 s. c  o m
 * @param binder
 *            a WebDataBinder object
 */
@InitBinder
public void initBinder(WebDataBinder binder) {
    if (binder.getTarget() instanceof Application) {
        binder.setAllowedFields("name");
    }
}