Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread run-time compiler binding error
Fri, Oct 28 2022 7:17 AMPermanent Link

Allen Hunt

Hi,

I'm trying to build my own TFileComboBox component and I'm still new to component development.  Can someone please provide an idea why this will not bind when I try to add it and rebuild the component library?  

{$IFNDEF BROWSER}
uses WebCore, WebUI;
{$ELSE}
uses WebDOM, WebCore, WebHTTP, WebUI;
{$ENDIF}

type
  {$IFNDEF BROWSER}
  external TFileInputElementExtended = class(TFileInputElement)
     public
        property AcceptTypes: String read write;
        procedure Click;
     end;

  {$ELSE}
  TFileInputElementExtended = class(TFileInputElement)
     protected
        function CreateDOMElement: THTMLElement; override;
     end;
  {$ENDIF}

There errors are:

Cannot bind to external class type TFileInputElementExtended
Cannot bind to external property AcceptTypes
Cannot bind to external method Click

Thank you!

Best regards,
Allen
Fri, Oct 28 2022 10:08 PMPermanent Link

Allen Hunt

Allen Hunt wrote:

> Can someone please provide an idea why this will not bind when I try to add it and rebuild the component library?  

I've managed to stumble past the issue but I don't have a permanent answer yet.  It's an IFDEF problem.  I'm trying to understand these in the help file and how it relates to the way the component library is built:

DESIGN Indicates that the code is being compiled for execution in the IDE
BROWSER Indicates that the code is being compiled for execution in a client application
RUNTIME Indicates that the code is being compiled for execution in a server application
CLIENT Indicates that the code is being compiled for client usage
SERVER Indicates that the code is being compiled for server usage
VERNNN Indicates the major/minor version of the Elevate Web Builder compiler, where NNN is the major/minor version number (without the period between the major and minor versions)

I'll do my best to post a solution if I figure it out.  Thank you!

Best regards,
Allen
Fri, Oct 28 2022 11:16 PMPermanent Link

Raul

Team Elevate Team Elevate

On 10/28/2022 7:17 AM, Allen Hunt wrote:
> Hi,
>
> I'm trying to build my own TFileComboBox component and I'm still new to component development.  Can someone please provide an idea why this will not bind when I try to add it and rebuild the component library?

This is just observation based on a super quick look so might be totally
wrong.

I don't believe TFileInputElement is itself a IDE component. It is a UI
element but not a component and does not implement many of the component
"things" - interface, GetInterfaceClassName, InitializeProperties etc

I'd suggest try to start with something that is UI component already and
go from there - basically go to library tab and do "new component" and
see if anything in the "ancestor component" list would be a good base.
If nothing else just a TComponent. And then you can use elements as UI
parts of the component.

Raul
Sat, Oct 29 2022 7:10 AMPermanent Link

Allen Hunt

Raul wrote:

On 10/28/2022 7:17 AM:

Thank you Raul!  Yea I'm still trying to grasp it.  I don't have a clear picture of GetInterfaceClassName, InitializeProperties, or even the InterfaceManager.RegisterElementClass.  Thank you for reminding me about the new component feature.  That did help.

It turns out I didn't even need the external TFileInputElement.  All I had to do was:

{$IFNDEF BROWSER}
uses WebCore, WebUI, WebCtrls, WebEdits;
{$ELSE}
uses WebDOM, WebCore, WebHTTP, WebUI, WebCtrls, WebEdits;
{$ENDIF}

type

     {$IFDEF BROWSER}
     TFileInputElementExtended = class(TInputElement)
        private
           FMultiple: Boolean;
           FChangeHandler: TEventHandler;
           function GetAcceptTypes: String;
           procedure SetAcceptTypes(const Value: String);
        protected
           function CreateDOMElement: THTMLElement; override;
           procedure SetDOMEventHandlers; override;
           procedure ClearDOMEventHandlers; override;
           procedure Update(AChanges: TSet; AInitialize: Boolean=False); override;
           procedure DoChange; virtual;
        public
           property AcceptTypes: String read GetAcceptTypes write SetAcceptTypes;
           procedure Click;
        end;
  {$ENDIF}

implementation

{$IFDEF BROWSER}
...
{$ENDIF}

I modified TFileComboBox's component FInputElement: TFileInputElement to allow for multiple files to be uploaded.  Here's a code snippet:

HTML_ATTR_MULTIPLE = 'multiple'

function TFileInputElement.CreateDOMElement: THTMLElement;
begin
  Result:=inherited CreateDOMElement;
  Result.setAttribute(HTML_ATTR_TYPE,HTML_VALUE_FILE);

  Result.setAttribute('multiple','');    // or Result.setAttribute(HTML_ATTR_MULTIPLE,'');  <--- add this right here
end;

Trying to understand all the different cycles the compiler appears to be going through when adding a component to the library, rebuilding the library, etc. is a task! Thank you so much!

Best regards,
Allen
Mon, Oct 31 2022 6:57 AMPermanent Link

Walter Matte

Tactical Business Corporation

Allen would you upload your Multiple File Upload component to the EWB components section of the forum?
Mon, Oct 31 2022 8:30 AMPermanent Link

Allen Hunt

Walter Matte wrote:

>  Allen would you upload your Multiple File Upload component to the EWB components section of the forum?

Sure!  I'm not done but I posted what I had.  I don't understand why InterfaceManager.RegisterElementClass( TFileInputElementExtended, HTML_TAG_INPUT ); in the InitializeProperties appears to be needed but it seems to be working for me now.  There is probably a correct answer somewhere.

I made RegisterElementClass public in the WebUI which I'm sure Tim will probably say is a no no.

As I learn more, I let you know!

Best regards,
Allen
Image