Consultor Eletrônico



Kbase P121522: How to use a SmartLobField to add, update, and save BLOB database field.
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   1/8/2007
Status: Unverified

GOAL:

Example of using a SmartLobField with the SmartToolBar too Add, update, and delete Blob images.

GOAL:

How to use a SmartLobField to add, update, and delete a BLOB database field.

FIX:

The following are step by step instructions on how to create a Smart Window that contains a SmartLobField used to add, update, and save an image to a BLOB database field.
1. Create a copy of the sports2000 database.
2. Using the Data Dictionary to add a field to the Customer table called 'blobpic'. Ensure this fields datatype is set to BLOB.
3. Create a Smart Window and save it as wBlob.w.
4. Create a SmartDataObject and add the Customer table to it. Add the custnum, name, and blobpic fields. Save the SDO as dcustomer.w.
5. Create a SmartLobField. Add and image, fill-in, and button widget to the SmartLobField Window. Rename the widgets as follows:
fill-in = fiChar
button = btn1
image = IMAGE-1
6. Modify the the SmartLobField Objects function fillData to:
DEFINE VARIABLE cImageFile AS CHARACTER NO-UNDO.
SUPER().
{get LOBFileName cImageFile}.
DO WITH FRAME {&FRAME-NAME}:
image-1:LOAD-IMAGE(cImageFile) NO-ERROR.
IF ERROR-STATUS:GET-MESSAGE(1) > '' THEN
image-1:LOAD-IMAGE('adeicon/blank').
END.
7. Modify the SmartLobField Objects procedure disableField to:
{set FieldEnabled FALSE}.
ASSIGN fiChar:SENSITIVE IN FRAME {&FRAME-NAME} = FALSE.
Btn1:SENSITIVE = FALSE.
8. Modify the SmartLobField Objects procedure clearField to:
IMAGE-1:LOAD-IMAGE('adeicon/blank') IN FRAME {&FRAME-NAME}.
9. Add the following to the CHOOSE trigger of btn1:
DEFINE VARIABLE lok AS LOGICAL NO-UNDO.
DEFINE VARIABLE cFile AS CHARACTER NO-UNDO.
cFile = fiChar:SCREEN-VALUE.
SYSTEM-DIALOG GET-FILE cFile
FILTERS "All Files (*.*)" "*.*",
"Bitmap Image (*.bmp)" "*.bmp",
"JPG Files(*.jpg) " "*.jpg",
"GIF Files (*.gif) " "*.gif"
MUST-EXIST
USE-FILENAME
UPDATE lOk.
IF lok THEN DO WITH FRAME {&FRAME-NAME}:
lOK = image-1:LOAD-IMAGE(cFile) NO-ERROR.
IF lOK THEN
DO:
{fnarg assignLOBFilename cfile}.
fiChar:SCREEN-VALUE IN FRAME {&FRAME-NAME} = cFile.
END.
END.
10. Save and close the SmartLob Field Object as LobCustomer.w
11. Create a SmartDataViewer. Use the dcustomer.w SDO that you created in Step 4. Add all the fields except blobpic as the wizard will reject this BLOB field. Save the SDV as vcustomer.w.
12. Add the SmartLobField to the SDV. The SmartLobField Object is not available on the object palette by default. You must goto the Menu of the palette and choose "Menu->SmartLobField->Choose SmartLobfield".
13. Once the SLF is on the SDV, right-click the SLF and choose 'instance properties'. Ensure that the blobpic field is added to the FieldName attribute and make sure the ENABLE toggle box is checked. Save and close the SDV again.
13. Add the SDO (dcustomer.w) and SDV (vcustomer.w) to the smartwindow (wblob.w) and accept the default links that the wizard assigns.
14. Add the SmartToolBar to the window and accept the default links the wizard assigns. Save the smartwindow (wblob.w).
15. You can now run the window. You can use the button to load an image and the SmartToolBar's icons will adjust properly allowing you to save the image back to the BLOB database field.