summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichael <michael@3ad0048d-3df7-0310-abae-a5850022a9f2>2010-06-04 15:24:27 +0000
committermichael <michael@3ad0048d-3df7-0310-abae-a5850022a9f2>2010-06-04 15:24:27 +0000
commit171ccdbe7d3dba2db50a3138f889bcdd5a6a6db0 (patch)
treee2fbc80d5f5a0d431ba459913c0600a6390767bd
parent670c2792af3be72fdb8cf26438ac7659d89e4da4 (diff)
downloadfpc-171ccdbe7d3dba2db50a3138f889bcdd5a6a6db0.tar.gz
* Ext.Direct demo
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@15375 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--packages/fcl-web/examples/jsonrpc/extdirect/extdemo.html12
-rw-r--r--packages/fcl-web/examples/jsonrpc/extdirect/extdemo.js44
-rw-r--r--packages/fcl-web/examples/jsonrpc/extdirect/extdemo.lpi261
-rw-r--r--packages/fcl-web/examples/jsonrpc/extdirect/extdemo.lpr15
-rw-r--r--packages/fcl-web/examples/jsonrpc/extdirect/extdirect.in4
-rw-r--r--packages/fcl-web/examples/jsonrpc/extdirect/wmext.lfm24
-rw-r--r--packages/fcl-web/examples/jsonrpc/extdirect/wmext.lrs10
-rw-r--r--packages/fcl-web/examples/jsonrpc/extdirect/wmext.pp52
8 files changed, 422 insertions, 0 deletions
diff --git a/packages/fcl-web/examples/jsonrpc/extdirect/extdemo.html b/packages/fcl-web/examples/jsonrpc/extdirect/extdemo.html
new file mode 100644
index 0000000000..00c017d004
--- /dev/null
+++ b/packages/fcl-web/examples/jsonrpc/extdirect/extdemo.html
@@ -0,0 +1,12 @@
+<html>
+<head>
+<title>ExtJS JSON Data demo</title>
+<link rel="stylesheet" type="text/css" href="/ext/resources/css/ext-all.css"/>
+<script src="/ext/adapter/ext/ext-base.js"></script>
+<script src="/ext/ext-all-debug.js"></script>
+<script src="extdemo.cgi/demo/API"></script>
+<script src="extdemo.js"></script>
+</head>
+<body>
+</body>
+</html> \ No newline at end of file
diff --git a/packages/fcl-web/examples/jsonrpc/extdirect/extdemo.js b/packages/fcl-web/examples/jsonrpc/extdirect/extdemo.js
new file mode 100644
index 0000000000..8d27255d1f
--- /dev/null
+++ b/packages/fcl-web/examples/jsonrpc/extdirect/extdemo.js
@@ -0,0 +1,44 @@
+/*
+ Define namespace FPC
+*/
+
+Ext.ns('FPC');
+
+/*
+ Include our server-side Ext.Direct API; The default name 'FPWeb' was used
+*/
+
+Ext.Direct.addProvider(FPWeb);
+
+/*
+ Callback used to process result. It will show the actual page
+*/
+
+FPC.ShowResult = function (Provider,Response) {
+ var panel = new Ext.Panel({
+ renderTo: Ext.getBody(),
+ frame: true,
+ title: "Adding 1.2 and 3.4 = " + Response.result,
+ height: 50,
+ width: 200,
+ html: "The result is : " + Response.result
+ });
+ panel.show();
+}
+
+/*
+ onReady callback function
+*/
+
+FPC.ShowPage = function () {
+ /*
+ Call our API, using FPC.ShowResult as the callback to process the result
+ */
+ DemoClass.Add(1.2, 3.4, FPC.ShowResult);
+}
+
+/*
+ Start Extjs
+*/
+
+Ext.onReady(FPC.ShowPage);
diff --git a/packages/fcl-web/examples/jsonrpc/extdirect/extdemo.lpi b/packages/fcl-web/examples/jsonrpc/extdirect/extdemo.lpi
new file mode 100644
index 0000000000..5ff3e6c5a7
--- /dev/null
+++ b/packages/fcl-web/examples/jsonrpc/extdirect/extdemo.lpi
@@ -0,0 +1,261 @@
+<?xml version="1.0"?>
+<CONFIG>
+ <ProjectOptions>
+ <Version Value="7"/>
+ <General>
+ <Flags>
+ <MainUnitHasCreateFormStatements Value="False"/>
+ <Runnable Value="False"/>
+ </Flags>
+ <MainUnit Value="0"/>
+ <TargetFileExt Value=""/>
+ <Title Value="Ext.Direct demo application"/>
+ <ResourceType Value="res"/>
+ <UseXPManifest Value="True"/>
+ <Icon Value="0"/>
+ <ActiveWindowIndexAtStart Value="0"/>
+ </General>
+ <VersionInfo>
+ <Language Value=""/>
+ <CharSet Value=""/>
+ <StringTable Comments="" CompanyName="" FileDescription="" FileVersion="" InternalName="" LegalCopyright="" LegalTrademarks="" OriginalFilename="" ProductName="" ProductVersion=""/>
+ </VersionInfo>
+ <PublishOptions>
+ <Version Value="2"/>
+ <IgnoreBinaries Value="False"/>
+ <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
+ <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
+ </PublishOptions>
+ <RunParams>
+ <local>
+ <FormatVersion Value="1"/>
+ <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
+ </local>
+ </RunParams>
+ <RequiredPackages Count="4">
+ <Item1>
+ <PackageName Value="lazwebextra"/>
+ <MinVersion Valid="True"/>
+ </Item1>
+ <Item2>
+ <PackageName Value="WebLaz"/>
+ </Item2>
+ <Item3>
+ <PackageName Value="LCL"/>
+ </Item3>
+ <Item4>
+ <PackageName Value="FCL"/>
+ </Item4>
+ </RequiredPackages>
+ <Units Count="12">
+ <Unit0>
+ <Filename Value="extdemo.lpr"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="extdemo"/>
+ <EditorIndex Value="1"/>
+ <WindowIndex Value="0"/>
+ <TopLine Value="1"/>
+ <CursorPos X="7" Y="6"/>
+ <UsageCount Value="24"/>
+ <Loaded Value="True"/>
+ </Unit0>
+ <Unit1>
+ <Filename Value="wmdemo.pp"/>
+ <ComponentName Value="FPWebModule1"/>
+ <ResourceBaseClass Value="DataModule"/>
+ <UnitName Value="wmdemo"/>
+ <EditorIndex Value="0"/>
+ <WindowIndex Value="0"/>
+ <TopLine Value="1"/>
+ <CursorPos X="21" Y="28"/>
+ <UsageCount Value="24"/>
+ <Loaded Value="True"/>
+ </Unit1>
+ <Unit2>
+ <Filename Value="wmext.pp"/>
+ <IsPartOfProject Value="True"/>
+ <ComponentName Value="DemoClass"/>
+ <ResourceBaseClass Value="DataModule"/>
+ <UnitName Value="wmext"/>
+ <EditorIndex Value="6"/>
+ <WindowIndex Value="0"/>
+ <TopLine Value="3"/>
+ <CursorPos X="22" Y="48"/>
+ <UsageCount Value="24"/>
+ <Loaded Value="True"/>
+ </Unit2>
+ <Unit3>
+ <Filename Value="../../../src/jsonrpc/fpextdirect.pp"/>
+ <UnitName Value="fpextdirect"/>
+ <IsVisibleTab Value="True"/>
+ <EditorIndex Value="7"/>
+ <WindowIndex Value="0"/>
+ <TopLine Value="185"/>
+ <CursorPos X="49" Y="196"/>
+ <UsageCount Value="12"/>
+ <Loaded Value="True"/>
+ </Unit3>
+ <Unit4>
+ <Filename Value="../../../src/jsonrpc/fpjsonrpc.pp"/>
+ <UnitName Value="fpjsonrpc"/>
+ <WindowIndex Value="0"/>
+ <TopLine Value="432"/>
+ <CursorPos X="6" Y="441"/>
+ <UsageCount Value="10"/>
+ </Unit4>
+ <Unit5>
+ <Filename Value="../../../../../lazarus/components/fpweb/reglazwebextra.pp"/>
+ <UnitName Value="reglazwebextra"/>
+ <EditorIndex Value="10"/>
+ <WindowIndex Value="0"/>
+ <TopLine Value="67"/>
+ <CursorPos X="56" Y="81"/>
+ <UsageCount Value="12"/>
+ <Loaded Value="True"/>
+ </Unit5>
+ <Unit6>
+ <Filename Value="wmext.lrs"/>
+ <EditorIndex Value="9"/>
+ <WindowIndex Value="0"/>
+ <TopLine Value="1"/>
+ <CursorPos X="1" Y="9"/>
+ <UsageCount Value="12"/>
+ <Loaded Value="True"/>
+ </Unit6>
+ <Unit7>
+ <Filename Value="../../../src/base/fpcgi.pp"/>
+ <UnitName Value="fpcgi"/>
+ <EditorIndex Value="2"/>
+ <WindowIndex Value="0"/>
+ <TopLine Value="1"/>
+ <CursorPos X="26" Y="20"/>
+ <UsageCount Value="12"/>
+ <Loaded Value="True"/>
+ </Unit7>
+ <Unit8>
+ <Filename Value="../../../src/base/custcgi.pp"/>
+ <UnitName Value="custcgi"/>
+ <EditorIndex Value="3"/>
+ <WindowIndex Value="0"/>
+ <TopLine Value="24"/>
+ <CursorPos X="33" Y="24"/>
+ <UsageCount Value="12"/>
+ <Loaded Value="True"/>
+ </Unit8>
+ <Unit9>
+ <Filename Value="../../../src/base/httpdefs.pp"/>
+ <UnitName Value="HTTPDefs"/>
+ <EditorIndex Value="4"/>
+ <WindowIndex Value="0"/>
+ <TopLine Value="1"/>
+ <CursorPos X="26" Y="38"/>
+ <UsageCount Value="12"/>
+ <Loaded Value="True"/>
+ </Unit9>
+ <Unit10>
+ <Filename Value="../../../src/base/custweb.pp"/>
+ <UnitName Value="custweb"/>
+ <EditorIndex Value="5"/>
+ <WindowIndex Value="0"/>
+ <TopLine Value="221"/>
+ <CursorPos X="17" Y="265"/>
+ <UsageCount Value="12"/>
+ <Loaded Value="True"/>
+ </Unit10>
+ <Unit11>
+ <Filename Value="../../../src/jsonrpc/webjsonrpc.pp"/>
+ <UnitName Value="webjsonrpc"/>
+ <EditorIndex Value="8"/>
+ <WindowIndex Value="0"/>
+ <TopLine Value="29"/>
+ <CursorPos X="27" Y="29"/>
+ <UsageCount Value="11"/>
+ <Loaded Value="True"/>
+ </Unit11>
+ </Units>
+ <JumpHistory Count="13" HistoryIndex="12">
+ <Position1>
+ <Filename Value="../../../../../lazarus/components/fpweb/reglazwebextra.pp"/>
+ <Caret Line="1" Column="1" TopLine="1"/>
+ </Position1>
+ <Position2>
+ <Filename Value="extdemo.lpr"/>
+ <Caret Line="1" Column="1" TopLine="1"/>
+ </Position2>
+ <Position3>
+ <Filename Value="extdemo.lpr"/>
+ <Caret Line="11" Column="1" TopLine="1"/>
+ </Position3>
+ <Position4>
+ <Filename Value="wmext.pp"/>
+ <Caret Line="6" Column="18" TopLine="2"/>
+ </Position4>
+ <Position5>
+ <Filename Value="../../../src/jsonrpc/fpextdirect.pp"/>
+ <Caret Line="376" Column="36" TopLine="370"/>
+ </Position5>
+ <Position6>
+ <Filename Value="../../../src/base/httpdefs.pp"/>
+ <Caret Line="1" Column="1" TopLine="1"/>
+ </Position6>
+ <Position7>
+ <Filename Value="../../../src/base/httpdefs.pp"/>
+ <Caret Line="936" Column="3" TopLine="929"/>
+ </Position7>
+ <Position8>
+ <Filename Value="../../../src/base/custweb.pp"/>
+ <Caret Line="1" Column="1" TopLine="1"/>
+ </Position8>
+ <Position9>
+ <Filename Value="../../../src/jsonrpc/fpextdirect.pp"/>
+ <Caret Line="397" Column="17" TopLine="368"/>
+ </Position9>
+ <Position10>
+ <Filename Value="../../../src/jsonrpc/fpextdirect.pp"/>
+ <Caret Line="29" Column="1" TopLine="26"/>
+ </Position10>
+ <Position11>
+ <Filename Value="../../../src/jsonrpc/fpextdirect.pp"/>
+ <Caret Line="398" Column="16" TopLine="373"/>
+ </Position11>
+ <Position12>
+ <Filename Value="../../../src/jsonrpc/fpextdirect.pp"/>
+ <Caret Line="413" Column="21" TopLine="379"/>
+ </Position12>
+ <Position13>
+ <Filename Value="../../../src/jsonrpc/webjsonrpc.pp"/>
+ <Caret Line="66" Column="14" TopLine="41"/>
+ </Position13>
+ </JumpHistory>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="8"/>
+ <Target>
+ <Filename Value="extdemo.cgi"/>
+ </Target>
+ <SearchPaths>
+ <IncludeFiles Value="$(ProjOutDir)/"/>
+ </SearchPaths>
+ <Parsing>
+ <SyntaxOptions>
+ <UseAnsiStrings Value="True"/>
+ </SyntaxOptions>
+ </Parsing>
+ <Other>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+ <Debugging>
+ <Exceptions Count="3">
+ <Item1>
+ <Name Value="EAbort"/>
+ </Item1>
+ <Item2>
+ <Name Value="ECodetoolError"/>
+ </Item2>
+ <Item3>
+ <Name Value="EFOpenError"/>
+ </Item3>
+ </Exceptions>
+ </Debugging>
+</CONFIG>
diff --git a/packages/fcl-web/examples/jsonrpc/extdirect/extdemo.lpr b/packages/fcl-web/examples/jsonrpc/extdirect/extdemo.lpr
new file mode 100644
index 0000000000..92cc762972
--- /dev/null
+++ b/packages/fcl-web/examples/jsonrpc/extdirect/extdemo.lpr
@@ -0,0 +1,15 @@
+program extdemo;
+
+{$mode objfpc}{$H+}
+
+uses
+ fpCGI, wmext;
+
+{$R *.res}
+
+begin
+ Application.Title:='Ext.Direct demo application';
+ Application.Initialize;
+ Application.Run;
+end.
+
diff --git a/packages/fcl-web/examples/jsonrpc/extdirect/extdirect.in b/packages/fcl-web/examples/jsonrpc/extdirect/extdirect.in
new file mode 100644
index 0000000000..6d4049bb4a
--- /dev/null
+++ b/packages/fcl-web/examples/jsonrpc/extdirect/extdirect.in
@@ -0,0 +1,4 @@
+[
+ { "action": "DemoClass", "method": "add", "data": [1 , 2 ] , "tid": 1 },
+ { "action": "DemoClass", "method": "add", "data": [1.2 , 3.4] , "tid": 2 }
+] \ No newline at end of file
diff --git a/packages/fcl-web/examples/jsonrpc/extdirect/wmext.lfm b/packages/fcl-web/examples/jsonrpc/extdirect/wmext.lfm
new file mode 100644
index 0000000000..ecb823236a
--- /dev/null
+++ b/packages/fcl-web/examples/jsonrpc/extdirect/wmext.lfm
@@ -0,0 +1,24 @@
+object DemoClass: TDemoClass
+ OldCreateOrder = False
+ APIPath = 'API'
+ RouterPath = 'Router'
+ Height = 313
+ HorizontalOffset = 548
+ VerticalOffset = 230
+ Width = 359
+ object Add: TJSONRPCHandler
+ OnExecute = AddExecute
+ Options = []
+ ParamDefs = <
+ item
+ Name = 'A'
+ DataType = jtNumber
+ end
+ item
+ Name = 'B'
+ DataType = jtNumber
+ end>
+ left = 56
+ top = 32
+ end
+end
diff --git a/packages/fcl-web/examples/jsonrpc/extdirect/wmext.lrs b/packages/fcl-web/examples/jsonrpc/extdirect/wmext.lrs
new file mode 100644
index 0000000000..18013d4c89
--- /dev/null
+++ b/packages/fcl-web/examples/jsonrpc/extdirect/wmext.lrs
@@ -0,0 +1,10 @@
+{ This is an automatically generated lazarus resource file }
+
+LazarusResources.Add('TDemoClass','FORMDATA',[
+ 'TPF0'#10'TDemoClass'#9'DemoClass'#14'OldCreateOrder'#8#7'APIPath'#6#3'API'#10
+ +'RouterPath'#6#6'Router'#6'Height'#3'9'#1#16'HorizontalOffset'#3'$'#2#14'Ver'
+ +'ticalOffset'#3#230#0#5'Width'#3'g'#1#0#15'TJSONRPCHandler'#3'Add'#9'OnExecu'
+ +'te'#7#10'AddExecute'#7'Options'#11#0#9'ParamDefs'#14#1#4'Name'#6#1'A'#8'Dat'
+ +'aType'#7#8'jtNumber'#0#1#4'Name'#6#1'B'#8'DataType'#7#8'jtNumber'#0#0#4'lef'
+ +'t'#2'8'#3'top'#2' '#0#0#0
+]);
diff --git a/packages/fcl-web/examples/jsonrpc/extdirect/wmext.pp b/packages/fcl-web/examples/jsonrpc/extdirect/wmext.pp
new file mode 100644
index 0000000000..0d5c57a53a
--- /dev/null
+++ b/packages/fcl-web/examples/jsonrpc/extdirect/wmext.pp
@@ -0,0 +1,52 @@
+unit wmext;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes, SysUtils, FileUtil, LResources, HTTPDefs, websession, fpHTTP, fpWeb,
+ fpjsonrpc, webjsonrpc, fpextdirect, fpjson;
+
+type
+
+ { TDemoClass }
+
+ TDemoClass = class(TExtDirectModule)
+ Add: TJSONRPCHandler;
+ procedure AddExecute(Sender: TObject; const Params: TJSONData; out
+ Res: TJSONData);
+ private
+ { private declarations }
+ public
+ { public declarations }
+ end;
+
+var
+ DemoClass: TDemoClass;
+
+implementation
+
+{ TDemoClass }
+
+procedure TDemoClass.AddExecute(Sender: TObject;
+ const Params: TJSONData; out Res: TJSONData);
+
+Var
+ A,B : TJSONData;
+
+begin
+ If (Params is TJSONArray) then
+ begin
+ A:=TJSONArray(Params).Items[0];
+ B:=TJSONArray(Params).Items[1];
+ Res:=TJSONFLoatNumber.Create(B.AsFloat+A.AsFloat);
+ end;
+end;
+
+initialization
+ {$I wmext.lrs}
+
+ RegisterHTTPModule('demo', TDemoClass);
+end.
+