public class InputFileMimetypeValidator extends Object implements javax.faces.validator.Validator, javax.faces.component.StateHolder
Validates an InputFileInfo
blob value in case it's been uploaded. Accepted mimetypes are set using the
"extensions" attribute, representing the list of accepted extension suffixes separated by commas (for instance:
".jpeg, .png").
Validation is done on the filename, no actual mimetype check is done for now.
Modifier and Type | Field and Description |
---|---|
static String |
MIMETYPE_AUTHORIZED_EXTENSIONS_MESSAGE_ID
The message identifier of the
FacesMessage to be created if the authorized
extensions check fails. |
static String |
MIMETYPE_UNAUTHORIZED_EXTENSIONS_MESSAGE_ID
The message identifier of the
FacesMessage to be created if the unauthorized
extensions check fails. |
static String |
VALIDATOR_ID |
Constructor and Description |
---|
InputFileMimetypeValidator() |
Modifier and Type | Method and Description |
---|---|
String[] |
getExtensions() |
boolean |
isAuthorized() |
boolean |
isHidden() |
boolean |
isTransient() |
void |
restoreState(javax.faces.context.FacesContext context,
Object state) |
Object |
saveState(javax.faces.context.FacesContext context) |
void |
setAuthorized(boolean authorized) |
void |
setExtensions(String[] extensions) |
void |
setHidden(boolean hidden) |
void |
setTransient(boolean newTransientValue) |
void |
validate(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
Object value) |
public static final String VALIDATOR_ID
public static final String MIMETYPE_AUTHORIZED_EXTENSIONS_MESSAGE_ID
FacesMessage
to be created if the authorized
extensions check fails. The message format string for this message may optionally include the following
placeholders:
{0}
replaced by the configured auhtorized extensions.public static final String MIMETYPE_UNAUTHORIZED_EXTENSIONS_MESSAGE_ID
FacesMessage
to be created if the unauthorized
extensions check fails. The message format string for this message may optionally include the following
placeholders:
{0}
replaced by the configured unauthorized extensions.public InputFileMimetypeValidator()
public void validate(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Object value) throws javax.faces.validator.ValidatorException
validate
in interface javax.faces.validator.Validator
javax.faces.validator.ValidatorException
public String[] getExtensions()
public void setExtensions(String[] extensions)
public boolean isAuthorized()
public void setAuthorized(boolean authorized)
public boolean isHidden()
public void setHidden(boolean hidden)
public boolean isTransient()
isTransient
in interface javax.faces.component.StateHolder
public void setTransient(boolean newTransientValue)
setTransient
in interface javax.faces.component.StateHolder
public Object saveState(javax.faces.context.FacesContext context)
saveState
in interface javax.faces.component.StateHolder
public void restoreState(javax.faces.context.FacesContext context, Object state)
restoreState
in interface javax.faces.component.StateHolder
Copyright © 2016 Nuxeo SA. All rights reserved.