Class SingleFileComponent
- java.lang.Object
-
- javax.faces.component.UIComponent
-
- javax.faces.component.UIComponentBase
-
- javax.faces.component.UINamingContainer
-
- de.xima.fc.prompt.service.support.gui.component.SingleFileComponent
-
- All Implemented Interfaces:
ValidationCallbackMixin,EventListener,javax.faces.component.NamingContainer,javax.faces.component.PartialStateHolder,javax.faces.component.StateHolder,javax.faces.component.TransientStateHolder,javax.faces.component.UniqueIdVendor,javax.faces.event.ComponentSystemEventListener,javax.faces.event.FacesListener,javax.faces.event.SystemEventListenerHolder
public class SingleFileComponent extends javax.faces.component.UINamingContainer implements ValidationCallbackMixin
Component class for the<xp:singleFile />component. Also contains various helper methods needed by the component's XHTML page.- Since:
- 8.5.0
-
-
Field Summary
-
Fields inherited from class javax.faces.component.UINamingContainer
COMPONENT_FAMILY, COMPONENT_TYPE, SEPARATOR_CHAR_PARAM_NAME
-
-
Constructor Summary
Constructors Constructor Description SingleFileComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidencodeBegin(javax.faces.context.FacesContext context)StringgetDisplayTextFileName()Gets the display text for the file name of the dynamic file parameter.StringgetDisplayTextFileTypes()Gets the display text for the file types of the dynamic file parameter.StringgetDisplayTextMultiplicity()Gets the display text for the multiplicity of the dynamic file parameter.StringgetDisplayTextSource()Gets the display text for the source of the prompt file.PromptFileSetParametergetDynamicFile()List<String>getFileTypeExtensions()Assumes that this method is called within a context where an EL expression "#{item}" resolves to the currentPromptFileSetParameterinstance, i.e. at the proper position within the XHTML page.Set<PromptFileType.PromptFileKind>getFileTypeKinds()Assumes that this method is called within a context where an EL expression "#{item}" resolves to the currentPromptFileSetParameterinstance, i.e. at the proper position within the XHTML page.List<javax.faces.model.SelectItem>getKinds()Returns the list of availablekindsasSelectItems, e.g. for use as select options in a dropdown menu.List<javax.faces.model.SelectItem>getMultiplicities()Returns the list of availablemultiplicitiesasSelectItems, e.g. for use as select options in a dropdown menu.List<javax.faces.model.SelectItem>getSources()Returns a list of available options for the source of the file, i.e. no file, a static file, or a dynamic file.PromptConfigFilegetStaticFile()booleanisShowDynamic()booleanisShowStatic()voidonChangeSource(PromptFileSource source)Callback invoked when the user changes the source of the prompt config file.voidonFileDelete(javax.faces.event.ActionEvent event)Callback invoked when the user clicked on the delete button of the prompt config file.org.primefaces.model.StreamedContentonFileDownload()Callback invoked when the user clicks on the download button to download the existing prompt config file.voidonFileUpload(org.primefaces.event.FileUploadEvent event)Callback invoked when the user uploads a static file.voidprocessUpdates(javax.faces.context.FacesContext context)voidprocessValidators(javax.faces.context.FacesContext context)voidsetFileTypeExtensions(List<String> fileTypeExtensions)Sets the file type extensions for the current parameter, by modifying the list returned bygetFileTypeExtensions().voidsetFileTypeKinds(Set<PromptFileType.PromptFileKind> fileTypeKinds)Sets the file type kinds for the current parameter, by modifying the set returned bygetFileTypeKinds().booleanvalidateSelf(javax.faces.context.FacesContext context)Validates the component (and not its children), returning whether it is valid or not.-
Methods inherited from class javax.faces.component.UINamingContainer
createUniqueId, getFamily, getSeparatorChar, visitTree
-
Methods inherited from class javax.faces.component.UIComponentBase
addClientBehavior, addFacesListener, broadcast, clearInitialState, decode, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processDecodes, processRestoreState, processSaveState, queueEvent, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding, subscribeToEvent, unsubscribeFromEvent
-
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression
-
-
-
-
Method Detail
-
encodeBegin
public void encodeBegin(javax.faces.context.FacesContext context) throws IOException- Overrides:
encodeBeginin classjavax.faces.component.UIComponentBase- Throws:
IOException
-
getDisplayTextFileName
public String getDisplayTextFileName()
Gets the display text for the file name of the dynamic file parameter. Includes HTML markup for the inline editing feature that lets the user click on the file name to edit it.- Returns:
- The display text for the file name.
-
getDisplayTextFileTypes
public String getDisplayTextFileTypes()
Gets the display text for the file types of the dynamic file parameter. Includes HTML markup for the inline editing feature that lets the user click on the file types to edit them.- Returns:
- The display text for the file types.
-
getDisplayTextMultiplicity
public String getDisplayTextMultiplicity()
Gets the display text for the multiplicity of the dynamic file parameter. Includes HTML markup for the inline editing feature that lets the user click on the multiplicity to edit it.- Returns:
- The display text for the multiplicity.
-
getDisplayTextSource
public String getDisplayTextSource()
Gets the display text for the source of the prompt file. Includes HTML markup for the inline editing feature that lets the user click on the source to edit it.- Returns:
- The display text for the source.
-
getDynamicFile
public PromptFileSetParameter getDynamicFile()
- Returns:
- The dynamic file parameter.
-
getFileTypeExtensions
public List<String> getFileTypeExtensions()
Assumes that this method is called within a context where an EL expression "#{item}" resolves to the currentPromptFileSetParameterinstance, i.e. at the proper position within the XHTML page.Reads the parameter from the
itemEL variable and returns a modifiable list view of filePromptFileType.Extension.getExtension()backed byPromptFileSetParameter.getFileTypes().- Returns:
- A modifiable list of file extensions for the current parameter.
-
setFileTypeExtensions
public void setFileTypeExtensions(List<String> fileTypeExtensions)
Sets the file type extensions for the current parameter, by modifying the list returned bygetFileTypeExtensions().- Parameters:
fileTypeExtensions- The new list of file type extensions.
-
getFileTypeKinds
public Set<PromptFileType.PromptFileKind> getFileTypeKinds()
Assumes that this method is called within a context where an EL expression "#{item}" resolves to the currentPromptFileSetParameterinstance, i.e. at the proper position within the XHTML page.Reads the parameter from the
itemEL variable and returns a modifiable set view offile type kindsbacked byPromptFileSetParameter.getFileTypes().- Returns:
- A modifiable set of file type kinds for the current parameter.
-
setFileTypeKinds
public void setFileTypeKinds(Set<PromptFileType.PromptFileKind> fileTypeKinds)
Sets the file type kinds for the current parameter, by modifying the set returned bygetFileTypeKinds().- Parameters:
fileTypeKinds- The new set of file type kinds.
-
getKinds
public List<javax.faces.model.SelectItem> getKinds()
Returns the list of availablekindsasSelectItems, e.g. for use as select options in a dropdown menu.- Returns:
- The list of available file kinds.
-
getMultiplicities
public List<javax.faces.model.SelectItem> getMultiplicities()
Returns the list of availablemultiplicitiesasSelectItems, e.g. for use as select options in a dropdown menu.- Returns:
- The list of available multiplicities.
-
getSources
public List<javax.faces.model.SelectItem> getSources()
Returns a list of available options for the source of the file, i.e. no file, a static file, or a dynamic file.- Returns:
- The list of available sources.
-
getStaticFile
public PromptConfigFile getStaticFile()
Gets the static file, when thesourceis set toSTATIC. May be null when no static file is uploaded.- Returns:
- The static prompt config file.
-
isShowDynamic
public boolean isShowDynamic()
- Returns:
- True if the dynamic file UI should be shown, false otherwise.
-
isShowStatic
public boolean isShowStatic()
- Returns:
- True if the static file UI should be shown, false otherwise.
-
onChangeSource
public void onChangeSource(PromptFileSource source)
Callback invoked when the user changes the source of the prompt config file. Updates the model to reflect the new source.- Parameters:
source- The new source selected by the user.
-
onFileDelete
public void onFileDelete(javax.faces.event.ActionEvent event)
Callback invoked when the user clicked on the delete button of the prompt config file. Removes the file.- Parameters:
event- The action event from the delete button click.
-
onFileDownload
public org.primefaces.model.StreamedContent onFileDownload()
Callback invoked when the user clicks on the download button to download the existing prompt config file.- Returns:
- A
StreamedContentwith the file's content, name, and MIME type.
-
onFileUpload
public void onFileUpload(org.primefaces.event.FileUploadEvent event)
Callback invoked when the user uploads a static file.- Parameters:
event- The event containing the uploaded files
-
processUpdates
public void processUpdates(javax.faces.context.FacesContext context)
- Overrides:
processUpdatesin classjavax.faces.component.UIComponentBase
-
processValidators
public void processValidators(javax.faces.context.FacesContext context)
- Specified by:
processValidatorsin interfaceValidationCallbackMixin- Overrides:
processValidatorsin classjavax.faces.component.UIComponentBase
-
validateSelf
public boolean validateSelf(javax.faces.context.FacesContext context)
Description copied from interface:ValidationCallbackMixinValidates the component (and not its children), returning whether it is valid or not. You can add Faces messages within this method if validation fails.- Specified by:
validateSelfin interfaceValidationCallbackMixin- Parameters:
context- The current Faces context.- Returns:
- True if this component is valid, false otherwise.
-
-