com.silverpeas.form.displayers
Class AbstractFileFieldDisplayer

java.lang.Object
  extended by com.silverpeas.form.displayers.AbstractFieldDisplayer<FileField>
      extended by com.silverpeas.form.displayers.AbstractFileFieldDisplayer
All Implemented Interfaces:
FieldDisplayer<FileField>
Direct Known Subclasses:
FileFieldDisplayer, ImageFieldDisplayer, VideoFieldDisplayer

public abstract class AbstractFileFieldDisplayer
extends AbstractFieldDisplayer<FileField>

Author:
ehugonnet

Nested Class Summary
protected static class AbstractFileFieldDisplayer.Operation
          The different kinds of operation that can be applied into an attached file.
 
Field Summary
protected static String OPERATION_KEY
           
 
Constructor Summary
AbstractFileFieldDisplayer()
           
 
Method Summary
protected  void checkFieldType(String typeName, String contextCall)
          Checks the type of the field is as expected.
protected  SimpleDocument createSimpleDocument(String objectId, String componentId, org.apache.commons.fileupload.FileItem item, String fileName, String userId, boolean versionned)
           
protected  void deleteAttachment(String attachmentId, PagesContext pageContext)
          Deletes the specified attachment, identified by its unique identifier.?
 void displayScripts(PrintWriter out, FieldTemplate template, PagesContext pageContext)
          Prints the javascripts which will be used to control the new value given to the named field.
 String[] getManagedTypes()
          Returns the name of the managed types.
protected  boolean isDeletion(AbstractFileFieldDisplayer.Operation operation, String attachmentId)
          Is the specified operation is a deletion?
 boolean isDisplayedMandatory()
           
protected  boolean isUpdate(AbstractFileFieldDisplayer.Operation operation, String attachmentId)
          Is the specified operation is an update?
protected  String processInput(List<org.apache.commons.fileupload.FileItem> items, FileField field, PagesContext pageContext)
           
protected  String processUploadedFile(List<org.apache.commons.fileupload.FileItem> items, String parameterName, PagesContext pagesContext)
           
 List<String> update(List<org.apache.commons.fileupload.FileItem> items, FileField field, FieldTemplate template, PagesContext pageContext)
          Updates the value of the field.
 List<String> update(String attachmentId, FileField field, FieldTemplate template, PagesContext pagesContext)
          Updates the value of the field.
 
Methods inherited from class com.silverpeas.form.displayers.AbstractFieldDisplayer
index
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.silverpeas.form.FieldDisplayer
display, getNbHtmlObjectsDisplayed
 

Field Detail

OPERATION_KEY

protected static final String OPERATION_KEY
See Also:
Constant Field Values
Constructor Detail

AbstractFileFieldDisplayer

public AbstractFileFieldDisplayer()
Method Detail

createSimpleDocument

protected SimpleDocument createSimpleDocument(String objectId,
                                              String componentId,
                                              org.apache.commons.fileupload.FileItem item,
                                              String fileName,
                                              String userId,
                                              boolean versionned)
                                       throws IOException
Throws:
IOException

deleteAttachment

protected void deleteAttachment(String attachmentId,
                                PagesContext pageContext)
Deletes the specified attachment, identified by its unique identifier.?

Parameters:
attachmentId - the unique identifier of the attachment to delete.
pageContext - the context of the page.

getManagedTypes

public String[] getManagedTypes()
Returns the name of the managed types.

Returns:

displayScripts

public void displayScripts(PrintWriter out,
                           FieldTemplate template,
                           PagesContext pageContext)
                    throws IOException
Prints the javascripts which will be used to control the new value given to the named field. The error messages may be adapted to a local language. The FieldTemplate gives the field type and constraints. The FieldTemplate gives the local labeld too. Never throws an Exception but log a silvertrace and writes an empty string when :

Parameters:
pageContext -
Throws:
IOException

update

public List<String> update(List<org.apache.commons.fileupload.FileItem> items,
                           FileField field,
                           FieldTemplate template,
                           PagesContext pageContext)
                    throws FormException
Description copied from interface: FieldDisplayer
Updates the value of the field. The fieldName must be used to retrieve the HTTP parameter from the request. @throw FormException if the field type is not a managed type. @throw FormException if the field doesn't accept the new value.

Specified by:
update in interface FieldDisplayer<FileField>
Overrides:
update in class AbstractFieldDisplayer<FileField>
Returns:
Throws:
FormException

processInput

protected String processInput(List<org.apache.commons.fileupload.FileItem> items,
                              FileField field,
                              PagesContext pageContext)

update

public List<String> update(String attachmentId,
                           FileField field,
                           FieldTemplate template,
                           PagesContext pagesContext)
                    throws FormException
Description copied from interface: FieldDisplayer
Updates the value of the field. The fieldName must be used to retrieve the HTTP parameter from the request. @throw FormException if the field type is not a managed type. @throw FormException if the field doesn't accept the new value.

Returns:
Throws:
FormException

isDeletion

protected boolean isDeletion(AbstractFileFieldDisplayer.Operation operation,
                             String attachmentId)
Is the specified operation is a deletion?

Parameters:
operation - the operation.
attachmentId - the identifier of the attachment on which the operation is.
Returns:
true if the operation is a deletion, false otherwise.

isUpdate

protected boolean isUpdate(AbstractFileFieldDisplayer.Operation operation,
                           String attachmentId)
Is the specified operation is an update?

Parameters:
operation - the operation.
attachmentId - the identifier of the attachment on which the operation is.
Returns:
true if the operation is an update, false otherwise.

processUploadedFile

protected String processUploadedFile(List<org.apache.commons.fileupload.FileItem> items,
                                     String parameterName,
                                     PagesContext pagesContext)
                              throws IOException
Throws:
IOException

isDisplayedMandatory

public boolean isDisplayedMandatory()

checkFieldType

protected void checkFieldType(String typeName,
                              String contextCall)
Checks the type of the field is as expected. The field must be of type file.

Parameters:
typeName - the name of the type.
contextCall - the context of the call: which is the caller of this method. This parameter is used for trace purpose.


Copyright © 2016 Silverpeas. All Rights Reserved.