|
SilverStream Application Server 3.5 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JPanel | +--com.sssw.rt.atlas.AtPanel | +--com.sssw.rt.atlas.AtCanvas | +--com.sssw.rt.form.PvBaseCanvas | +--com.sssw.rt.form.PvInvisibleControlBase | +--com.sssw.rt.form.AgcFileAttachment
The File Attachment Control (AgcFileAttachment) is a databound control for storing file attachments in a database.
This control must be bound to a database column. The contents of the file attachment must be stored in a long varbinary column. The control is visible while in the Form Designer, but it is not at runtime.
Because of Java security restrictions, AgcFileAttachment can only be used with applications deployed using SilverJRunner.
Note: The ancestor methods in this class, that is all methods inherited from the non-public PvInvisibleControlBase (including JComponent and Component) are not visible at run time, and are primarily for use by SilverStream. The useful methods are contained in the AgcFileAttachment class itself.
Inner classes inherited from class javax.swing.JPanel |
JPanel.AccessibleJPanel |
Inner classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
Fields inherited from class com.sssw.rt.atlas.AtPanel |
BGIMAGE_DRAW_CENTERED,
BGIMAGE_DRAW_NORMAL,
BGIMAGE_DRAW_STRETCH,
BGIMAGE_DRAW_TILED |
Fields inherited from class javax.swing.JComponent |
accessibleContext,
listenerList,
TOOL_TIP_TEXT_KEY,
ui,
UNDEFINED_CONDITION,
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
WHEN_FOCUSED,
WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
LEFT_ALIGNMENT,
RIGHT_ALIGNMENT,
TOP_ALIGNMENT |
Constructor Summary | |
AgcFileAttachment()
|
Method Summary | |
File |
chooseFile(String caption,
File defaultFile,
boolean forSaving)
Displays a dialog box to the user which prompts for a local file or filename. |
void |
deleteFile(File file)
Displays a dialog box that warns the user that the named file will be deleted, then deletes it. |
void |
download(File localFile,
boolean launch)
Displays a warning dialog box to the user, stores the referenced resource in a local file, and then optionally launches the application for that file. |
Object |
getContents()
Gets the contents of the attachment as an object. |
void |
launchFile(File file)
Notifies the user then launches the registered program for the specified file. |
InputStream |
readAndDeleteFile(File file)
Notifies the user (once), returns an InputStream to the specified file, then deletes the file when the stream is closed. |
InputStream |
readFile(File file)
Returns an input stream from the referenced file. |
void |
setContents(Object contents)
Updates or inserts the Object to the field to which the AgcFileAttachment is bound. |
void |
upload(File localFile,
boolean delete)
Uploades the local file to the database column to which the AgcFileAttachment is bound. |
OutputStream |
writeAndLaunchFile(File file)
Notifies the user, creates a local file, then launches its associated application. |
OutputStream |
writeFile(File file)
Notifies the user then writes to a local file. |
Methods inherited from class com.sssw.rt.form.PvInvisibleControlBase |
setBounds,
setLocation,
setSize |
Methods inherited from class com.sssw.rt.form.PvBaseCanvas |
getBackgroundColor,
getFontIdentifier,
setBackgroundColor,
setFontIdentifier |
Methods inherited from class com.sssw.rt.atlas.AtPanel |
addImpl,
addNotify,
clientPaint,
clientPaint,
deliverMouseEvent,
deliverMouseMoveEvent,
doAtCommand,
drawTiledImage,
enableAtCommands,
getBackgroundImage,
getBackgroundImageMode,
getHelper,
getTransparent,
hide,
hideToolTip,
imageUpdate,
isFocusTraversable,
isOptimizedDrawingEnabled,
ownedImage,
paintBorder,
paintComponent,
paintImmediately,
paintImmediately,
paintNow,
preprocessKeyEvent,
processEvent,
reshape,
setBackgroundImage,
setBackgroundImageMode,
setTransparent,
show,
showToolTip |
Methods inherited from class javax.swing.JPanel |
getAccessibleContext,
getUIClassID,
paramString,
updateUI |
Methods inherited from class java.awt.Container |
add,
add,
add,
add,
add,
addContainerListener,
countComponents,
deliverEvent,
doLayout,
findComponentAt,
findComponentAt,
getComponent,
getComponentAt,
getComponentAt,
getComponentCount,
getComponents,
getLayout,
insets,
invalidate,
isAncestorOf,
layout,
list,
list,
locate,
minimumSize,
paintComponents,
preferredSize,
printComponents,
processContainerEvent,
remove,
remove,
removeAll,
removeContainerListener,
setCursor,
setLayout,
validate,
validateTree |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Methods implemented from interface com.sssw.rt.form.AgiControl |
getComponent,
getHelpInfo,
setHelpInfo |
Constructor Detail |
public AgcFileAttachment()
Method Detail |
public Object getContents()
Object contents; contents = attachment1.getContents();
public void setContents(Object contents) throws AgoSecurityException, AgoTransientSystemException, AgoUnrecoverableSystemException, AgoInvalidDataException, AgoMissingDataException, AgoDataConcurrencyException, AgoApplicationException
contents
- The AgcFileAttachment submits the update request directly to the SilverStream Server and bypasses the form's data buffering and transaction handling. If a record exists, then the record is updated. If the record does not exist, then a new record is inserted.
If setContents()
is called before calling updateRows()
on the form's agData, a 'duplicate key' error might result because setContents()
has updated the database directly.
Object newContents; newContents = new byte[50]; // populate the byte array with binary data try { attachment1.setContents(newContents); } catch (AgoApiException e) { agDialog.displayError(e); }
AgoSecurityException
,
AgoTransientSystemException
,
AgoUnrecoverableSystemException
,
AgoInvalidDataException
,
AgoMissingDataException
,
AgoDataConcurrencyException
public void download(File localFile, boolean launch) throws AgoSecurityException, IOException
localfile
- specifies the file and path for the file to download.launch
- specifies whether to launch the file (true) or not (false).SilverStream launches an application for the file based on the registry entry for the file's extension.
File storageFile; storageFile = new File("c:\\directory\\file"); try { attachment1.download(storageFile,true); } catch (Exception e) { agDialog.displayError(e); }
AgoSecurityException
public void upload(File localFile, boolean delete) throws AgoSecurityException, AgoTransientSystemException, AgoUnrecoverableSystemException, AgoInvalidDataException, AgoMissingDataException, AgoDataConcurrencyException, IOException
localfile
- specifies the file and path for the file to upload.delete
- specifies whether to delete (true) the local file or
not (false) after uploading it.The AgcFileAttachment submits the request directly to the SilverStream Server and bypasses the form's data buffering and transaction handling. If a record exists, then the record is updated. If a record does not exist, then a new record is inserted.
If delete is set to true, SilverStream deletes the local file once the upload is completed.
If upload()
is called before calling updateRows()
on the form's
agData, a 'duplicate key' error might result because upload()
updates
the database directly.
File fileToUpload; fileToUpload = new File("c:\\directory\\file"); try { attachment1.upload(fileToUpload,true); } catch (Exception e) { agDialog.displayError(e); }
AgoSecurityException
,
AgoTransientSystemException
,
AgoUnrecoverableSystemException
,
AgoInvalidDataException
,
AgoMissingDataException
,
AgoDataConcurrencyException
public OutputStream writeFile(File file) throws AgoSecurityException, IOException
file
- specifies the file and path for the file to create.File fileToWrite; fileToWrite = new File("c:\\directory\\file"); OutputStream output; try { output = attachment1.writeFile(fileToWrite); } catch (Exception e) { agDialog.displayError(e); }
AgoSecurityException
public InputStream readFile(File file) throws AgoSecurityException, IOException
file
- specifies the file and path for the file to read.File fileToRead; fileToRead = new File("c:\\directory\\file"); InputStream input; try { input = attachment1.readFile(fileToRead); } catch (Exception e) { agDialog.displayError(e); }
AgoSecurityException
public void deleteFile(File file) throws AgoSecurityException, IOException
file
- specifies the file to delete.File fileToDelete; try { fileToDelete = attachment1.chooseFile("Choose a File to Delete",null,false); attachment1.deleteFile(fileToDelete); } catch (Exception e) { agDialog.displayError(e); }
AgoSecurityException
public void launchFile(File file) throws AgoSecurityException, IOException
file
- specifies the file and path for the file to launch.SilverStream launches an application for the file based on the registry entry for the file's extension.
File fileToLaunch; fileToLaunch = new File("c:\\directory\\file"); try { attachment1.launchFile(fileToLaunch); } catch (Exception e) { agDialog.displayError(e); }
AgoSecurityException
public File chooseFile(String caption, File defaultFile, boolean forSaving) throws AgoSecurityException
caption
- specifies a message to display on the Choose File dialog.defaultFile
- specifies the default for a path and file name to display in the Choose File dialog.forSaving
- specifies a boolean value that indicates whether the file is being chosen for saving or for reading.File defaultFile; defaultFile = new File("c:\\Directory\\File"); File chosenFile; try { chosenFile = attachment1.chooseFile("Choose a File",defaultFile,false); } catch (AgoSecurityException e) { agDialog.displayError(e); }
AgoSecurityException
public OutputStream writeAndLaunchFile(File file) throws AgoSecurityException, IOException
file
- specifies the file and path for the file.SilverStream launches an application for the file based on the registry entry for the file's extension. The file is launched when the OutputStream is closed.
File fileToWrite; fileToWrite = new File("c:\\directory\\file"); OutputStream output; try { output = AgcFileAttachment.writeAndLaunch(fileToWrite); } catch (Exception e) { agDialog.displayError(e); } // Write the contents of the file to the OutputStream
AgoSecurityException
public InputStream readAndDeleteFile(File file) throws AgoSecurityException, IOException
file
- specifies the file and path for the file to read and delete.File fileToRead; InputStream dataFromFile; try { fileToRead = attachment1.chooseFile("Choose a File to Read and Delete",null,false); dataFromFile = attachment1.readAndDeleteFile(fileToRead); } catch (Exception e) { agDialog.displayError(e); }
AgoSecurityException
|
SilverStream Application Server 3.5 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |