home *** CD-ROM | disk | FTP | other *** search
/ Delphi Anthology / aDELPHI.iso / Runimage / Delphi50 / Demos / Midas / InternetExpress / InetXCustom / showxml.pas < prev    next >
Pascal/Delphi Source File  |  1999-08-11  |  3KB  |  115 lines

  1. unit ShowXML;
  2.  
  3. interface
  4.  
  5. uses Classes, HTTPApp, Db, DbClient, Midas,
  6.   XMLBrokr, WebComp, MidItems;
  7.  
  8. type
  9.   TCustomShowXMLButton = class(TXMLButton, IScriptComponent)
  10.   protected
  11.     XMLMethodName: string;
  12.     { IScriptComponent }
  13.     procedure AddElements(AddIntf: IAddScriptElements);
  14.     function GetSubComponents: TObject;
  15.     { IWebContent implementation }
  16.     function ImplContent(Options: TWebContentOptions;
  17.       ParentLayout: TLayout): string; override;
  18.   end;
  19.  
  20.   TShowXMLButton = class(TCustomShowXMLButton)
  21.   public
  22.     constructor Create(AOwner: TComponent); override;
  23.   published
  24.     property Custom;
  25.     property Style;
  26.     property StyleRule;
  27.     property Caption;
  28.     property XMLBroker;
  29.     property XMLUseParent;
  30.   end;
  31.  
  32.   TShowDeltaButton = class(TCustomShowXMLButton)
  33.   public
  34.     constructor Create(AOwner: TComponent); override;
  35.   published
  36.     property Custom;
  37.     property Style;
  38.     property StyleRule;
  39.     property Caption;
  40.     property XMLBroker;
  41.     property XMLUseParent;
  42.   end;
  43.  
  44. implementation
  45.  
  46. uses sysutils, MidProd;
  47.  
  48. resourcestring 
  49.   sShowXML = 'Show XML';
  50.   sShowDelta = 'Show Delta';
  51.  
  52. procedure TCustomShowXMLButton.AddElements(
  53.   AddIntf: IAddScriptElements);
  54. begin
  55.   AddIntf.AddIncludeFile('xmlshow.js');
  56. end;
  57.  
  58. function TCustomShowXMLButton.GetSubComponents: TObject;
  59. begin
  60.   Result := nil;
  61. end;
  62.  
  63. function TCustomShowXMLButton.ImplContent(Options: TWebContentOptions;
  64.   ParentLayout: TLayout): string;
  65. var
  66.   Attrs: string;
  67.   Intf: ILayoutWebContent;
  68.   FormVarName: string;
  69.   RowSetVarName: string;
  70. begin
  71.   AddQuotedAttrib(Attrs, 'NAME', Name);
  72.   AddQuotedAttrib(Attrs, 'STYLE', Style);
  73.   AddQuotedAttrib(Attrs, 'CLASS', StyleRule);
  74.   AddQuotedAttrib(Attrs, 'VALUE', Self.Caption);
  75.   AddCustomAttrib(Attrs, Custom);
  76.   if Assigned(XMLData.XMLBroker) then
  77.   begin
  78.     FormVarName := XMLData.XMLBroker.SubmitFormVarName;
  79.     RowSetVarName := XMLData.XMLBroker.RowSetVarName(nil);  // Row row set var name
  80.   end;
  81.   if not (coNoScript in Options.Flags) then
  82.     Result :=
  83.       Format('<INPUT TYPE=BUTTON %0:s onclick=''if(%3:s)ShowXML(%1:s.%2:s);''>'#13#10,
  84.         [Attrs, RowSetVarName, XMLMethodName, sXMLReadyVar])
  85.   else
  86.     Result :=
  87.       Format('<INPUT TYPE=BUTTON %0:s>'#13#10,
  88.         [Attrs]);
  89.   if Assigned(ParentLayout) and ParentLayout.GetInterface(ILayoutWebContent, Intf) then
  90.     Result := Intf.LayoutButton(Result, GetLayoutAttributes);
  91. end;
  92.  
  93. { TShowXMLButton }
  94.  
  95. constructor TShowXMLButton.Create(AOwner: TComponent);
  96. begin
  97.   inherited;
  98.   DefaultCaption := sShowXML;
  99.   XMLMethodName := 'root';
  100. end;
  101.  
  102. { TShowDeltaButton }
  103.  
  104. constructor TShowDeltaButton.Create(AOwner: TComponent);
  105. begin
  106.   inherited;
  107.   DefaultCaption := sShowDelta;
  108.   XMLMethodName := 'getDelta()';
  109. end;
  110.  
  111. { Register procedure }
  112.  
  113.  
  114. end.
  115.