Adding Picture to ValueStorage; Form does not refresh

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Just came
1C:Professional
Rating: 1
Joined: Mar 7, 2016
Company: 4b-software UG

Hi, I need some help:
I want to show a picture from a ValueStorage in a form ImageField. The problem is, that the picture is not shown in the image field after file selection and picture address assignment. Here is my code:

Code
&AtServer
Procedure SetPictureValueAtServer(StorageName, ClearPicture)
   
   ObjectValue = FormDataToValue(Object, Type("CatalogObject.Products"));
   If ClearPicture Then
      ObjectValue.PictureStorage = Undefined;
   Else
      ObjectValue.PictureStorage = New ValueStorage(GetFromTempStorage(StorageName));
   EndIf;
   ObjectValue.Write();
    
   ValueToFormData(ObjectValue, Object);
    
EndProcedure

&AtClient
Procedure PictureClick(Item, StandardProcessing)
   StorageName = "";
   FileName = ""; 
    
   If PutFile(StorageName, FileName, FileName, True, UUID) Then
      SetPictureValueAtServer(StorageName, FALSE);
   EndIf;
    
   FormPictureAddress = GetURL(Object.Ref, "PictureStorage");
EndProcedure


I have to close and reopen the form, then I see the picture. I'm using this code on open form:

Code
&AtClient
Procedure OnOpen(Cancel)

   FormPictureAddress = GetURL(Object.Ref, "PictureStorage");
   
EndProcedure


And, very strange, if I comment out GetURL in procedure OnOpen
Code
Procedure OnOpen(Cancel)
   // FormPictureAddress = GetURL(Object.Ref, "PictureStorage");
EndProcedure

I dont't see picture after reopen form (shure), but if I select now a file (procedure PicturClick runs) it only works just once! Picture is shown imediatly before this message:

By the way, how can I suppress this message?

Thanks in advance for help
Michael

 
#2
People who like this:0Yes/0No
Active user
Rating: 2
Joined: Jan 14, 2013
Company:

You can use code :

Code
&AtClient
Procedure PictureClick(Command)
   BeginPutFile(New NotifyDescription("ChangePictureAfterPutFile", ThisForm), , , True, UUID);   
EndProcedure

&AtClient
Procedure ChangePictureAfterPutFile(Result, Address, SelectedFileName, AdditionalParameters) Export
   If Result Then
      FormPictureAddress = Address;
   EndIf;
EndProcedure

&AtServer
Procedure OnReadAtServer(CurrentObject)
   If  CurrentObject.PictureStorage <> Undefined then
      FormPictureAddress = GetURL(CurrentObject,"PictureStorage");   
   EndIf;
EndProcedure

&AtServer
Procedure BeforeWriteAtServer(Cancel, CurrentObject, WriteParameters)
   If IsTempStorageURL(FormPictureAddress) Then
      BinaryData = GetFromTempStorage(FormPictureAddress);
      CurrentObject.PictureStorage= New ValueStorage(BinaryData, New Deflation());
   EndIf;

EndProcedure

 
#3
People who like this:0Yes/0No
Just came
1C:Professional
Rating: 1
Joined: Mar 7, 2016
Company: 4b-software UG

Hello P&A,
this works. Thanks.
Michael

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.