Jump to content

mazluta

uniGUI Subscriber
  • Posts

    108
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mazluta

  1. but then, the dataset afterscroll not fire if record not selected. the user select the first 2 record. why to punish him and clear the selection?
  2. see the cursor is between the char 7 and the char d -> position 7 in the TUniEdit function keyup(sender, e, eOpts) { document.getElementById("M1234_aa-inputEl").value = e.target.selectionStart.toString(); the UniEdit just by Id name (given in the form create - edCCList.JSControl.Id := 'M1234_aa'; watch that the INPUT name is - M1234_aa-inputEl MySendMailFrm.ExtEventResultString.setText(e.target.selectionStart.toString()); the UniLabel by form name and component name }
  3. Denton - thank u very much. all your answer were OK
  4. in DELPHI desktop (the old one) i can get the name from is PARENT. can i do it here?
  5. i tryed. procedure TIturDocumentFrame.btnSendMailClick(Sender: TObject); Var FileAttche : String; begin If Not fIturResultFrame.DocumentsQry.Active Then Exit; If fIturResultFrame.DocumentsQry.RecordCount = 0 Then Exit; FileAttche := fIturResultFrame.DocumentsQry.FieldByName('Mz_FileName').AsString; NewSendMailFrm := TSendMailFrm.Create(UniApplication); NewSendMailFrm.FilesAttchLists.Add(FileAttche); NewSendMailFrm.ShowModal(CallBack_SendMail); end; the ExtEvent dont reconize this name and not - SendMailFrm
  6. i tried function keyup(sender, e, eOpts) { document.getElementById("M1234_aa-inputEl").value = e.target.selectionStart.toString(); /*document.getElementById("MyResultString").value = e.target.selectionStart.toString();*/ console.log("sender=" + sender); console.log("e=" + e); console.log("eOpts=" + eOpts); fLbl = document.getElementById("MyResultString"); fLbl.setText(e.target.selectionStart.toString()); } the result : sender=[object Object] - this give me nothing VM247:1 e=[object Object] VM247:1 eOpts=undefined how do i print to the console the TYPE of the obj like : sender= Ext.form.Field.Text
  7. one more Q. is there a way to change Var in PUBLIC (under the form/frame) area from the ExtEvent function ?
  8. WOW. thanks very much. a lot of reading. one more Q. i write keyup extevent like this : the purpose is to get the position of the cursor inside the text..... function keyup(sender, e, eOpts) { document.getElementById("M1234_aa-inputEl").value = e.target.selectionStart.toString(); /*document.getElementById("MyResultString").value = e.target.selectionStart.toString();*/ fLbl = document.getElementById("MyResultString"); fLbl.setText(e.target.selectionStart.toString()); } M1234_aa-inputEl -> is TUniedit and that work. MyResultString -> is some TUniLable - i want is caption to change to the same value - The SetText doesn't do nothing.
  9. 1. on my form i have 2 TUniEdit1 i want to add ExtEvent to TUniEdit1 onkeyup if the user click "^" in the TUniEdit1 i want to set TUniEdit1.Text to 'Hello' inside the OnKeyUp Clieck Event of the ExtEvent 2. in the ExtEvent, Whet is Sender? How Can I See What Is Members and Property Are? what is e - the same for Members and Property Are? what is eOpts - the same for Members and Property Are? 3. what is "document" or "windows" or "body" as relational to My FORM/FRAME 4. can i run ExtEvent OnKeyUp and the TUniEdit1.OnKeyUp on the same FORM/FRAME? what come first? is the ExtEvent is allwes ClientSide And Object.DelphiEvent is Server Side? 5. where can i find deeper documents on the ExtEvent for Older Delphi Developers
  10. is there example of UniAuxExceptionHandler and and madExcept ?
  11. the right way to call to ajaxrequest is : UniSession.AddJS('$.get("http://127.0.0.1:8989/GetMi", function( data ){' + ' ajaxRequest(' + ThisName + '.form, ["test"], { response : data });}); '); not sending the HEADER in the request : {headers: { "Access-Control-Allow-Origin": "*" }}
  12. ok. first - thanks to RON. i finally get the answer. in one of Thousands of posts i read, i found that : Accessing localhost If your website needs to issue requests to localhost, then you just need to upgrade your website to HTTPS. this was in : https://developer.chrome.com/blog/private-network-access-update/ since my test site was HTTP://HanibaalDemos:8077 chrome did not allow CORS. i bought new SSL certificate, add set SSL capability to the Site - and Vuala - it work. to run the WebService From The client side, Just Var ThisName : String; begin ThisName := Self.Name; JustWriteToLog('btnAddFilesFromListClick - Self.Name = ' + ThisName); JustWriteToLog('Before UniSession.AddJS($.get("http://127.0.0.1:8989/GetMi"...'); UniSession.AddJS('$.ajaxSetup({headers: { "Access-Control-Allow-Origin": "*" }});'); UniSession.AddJS('$.get("http://127.0.0.1:8989/GetMi", function( data ){' + ' ajaxRequest(' + ThisName + '.form, ["test"],{headers: { "Access-Control-Allow-Origin": "*" }}, { response : data });}); '); JustWriteToLog('After UniSession.AddJS($.get("http://127.0.0.1:8989/GetMi"...'); end; and Add Ajax Event For "Test" : procedure TSendMailFrm.UniFormAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin JustWriteToLog('EventName : ' + EventName); JustWriteToLog('Params : ' + Params.Text); if sameText(EventName, 'test') then edToList.Text:=Params.Values['response']; end; at the server side : in the WebModuleBeforeDispatch Event - procedure TWebModule1.WebModuleBeforeDispatch(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); begin JustWriteToLog('On WebModuleBeforeDispatch'); Response.CustomHeaders.Values['Access-Control-Allow-Origin'] := '*'; Response.CustomHeaders.Values['Access-Control-Allow-Headers'] := '*'; Response.CustomHeaders.Values['Access-Control-Allow-Methods'] := 'GET, POST, PUT, DELETE, OPTIONS'; Response.CustomHeaders.Values['Access-Control-Allow-Credentials'] := 'true'; Response.CustomHeaders.Values['Access-Control-Allow-Private-Network'] := '*'; Response.CustomHeaders.Values['Access-Control-Expose-Headers'] := ''; if Trim(Request.GetFieldByName('Access-Control-Request-Headers')) <> '' then begin JustWriteToLog('On WebModuleBeforeDispatch - Trim(Request.GetFieldByName(Access-Control-Request-Headers))'); //Response.SetCustomHeader('Access-Control-Allow-Headers', Request.GetFieldByName('Access-Control-Request-Headers')); Response.CustomHeaders.Values['Access-Control-Allow-Headers'] := Request.GetFieldByName('Access-Control-Request-Headers'); Handled := True; end; if SameText(Request.Method, 'OPTIONS') then begin JustWriteToLog('On WebModuleBeforeDispatch - if SameText(Request.Method, Option)'); Handled := True; end; if FServerFunctionInvokerAction <> nil then begin JustWriteToLog('On WebModuleBeforeDispatch - if FServerFunctionInvokerAction <> nil'); FServerFunctionInvokerAction.Enabled := AllowServerFunctionInvoker; end; end; now - we gat the backend door to control the local PC components/data from our cloud site
  13. Hi Ron i send you private message. No matter what I try, it doesn't work and always reports a problem with the CORS //// this is the server side procedure TWebModule1.WebModuleBeforeDispatch(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); begin JustWriteToLog('On WebModuleBeforeDispatch'); Response.SetCustomHeader('Access-Control-Allow-Origin','*'); Response.SetCustomHeader('Access-Control-Allow-Credentials','*'); Response.SetCustomHeader('Access-Control-Allow-Methods','*'); Response.SetCustomHeader('Access-Control-Allow-Private-Network','*'); Response.SetCustomHeader('Access-Control-Allow-Headers', '*'); //Response.SetCustomHeader('Access-Control-Allow-Headers', 'x-requested-with'); //Response.CustomHeaders.Values['Access-Control-Allow-Origin'] := '*'; //Response.CustomHeaders.Values['Access-Control-Allow-Credentials'] := 'true'; //Response.CustomHeaders.Values['Access-Control-Allow-Methods'] := 'GET, POST, PUT, DELETE, OPTIONS'; //Response.CustomHeaders.Values['Access-Control-Allow-Origin'] := '*'; //Response.CustomHeaders.Values['Access-Control-Allow-Credentials'] := '*'; //Response.CustomHeaders.Values['Access-Control-Allow-Methods'] := '*'; if Trim(Request.GetFieldByName('Access-Control-Request-Headers')) <> '' then begin JustWriteToLog('On WebModuleBeforeDispatch - Trim(Request.GetFieldByName(Access-Control-Request-Headers))'); Response.SetCustomHeader('Access-Control-Allow-Headers', Request.GetFieldByName('Access-Control-Request-Headers')); Handled := True; end; if SameText(Request.Method, 'Option') then begin JustWriteToLog('On WebModuleBeforeDispatch - if SameText(Request.Method, Option)'); Handled := True; end; if FServerFunctionInvokerAction <> nil then begin JustWriteToLog('On WebModuleBeforeDispatch - if FServerFunctionInvokerAction <> nil'); FServerFunctionInvokerAction.Enabled := AllowServerFunctionInvoker; end; end; // in the client side - i add header to request procedure TSendMailFrm.btnAddFilesFromListClick(Sender: TObject); Var ThisName : String; begin // UniSession.AddJS('$.get("http://127.0.0.1:8989/GetMi", function( data ){' + // ' ajaxRequest(SendMailFrm.form, ["test"], { response : data }); '+ // ' }); '); ThisName := Self.Name; JustWriteToLog('btnAddFilesFromListClick - Self.Name = ' + ThisName); JustWriteToLog('Before UniSession.AddJS($.get("http://127.0.0.1:8989/GetMi"...'); //UniSession.AddJS('$.get("http://127.0.0.1:8989/GetMi", function( data ){' + // ' ajaxRequest(' + ThisName + '.form, ["test"], { response : data });}); '); //UniSession.AddJS('$.ajaxSetup({headers: { "Access-Control-Allow-Origin": "*" }});'); UniSession.AddJS('$.get("http://127.0.0.1:8989/GetMi", function( data ){' + ' ajaxRequest(' + ThisName + '.form, ["test"],{headers: { "Access-Control-Allow-Origin": "*" }}, { response : data });}); '); JustWriteToLog('After UniSession.AddJS($.get("http://127.0.0.1:8989/GetMi"...'); end; +++++++++++++++++++++++++++++++++++++++++++++++++++++ the server is in the MzDataSnap-WebModule.zip the client is SendMail.zip i hope you can help by providing example for SERVER (rest) that allowing this CORS MzDataSnap-WebModule.zip SendMail.zip
  14. Hi All If we manage to run this service from the local computer, it will be possible to easily take control of external components, such as smart cards, scanners, special printers (plotters), run programs in local computer and receive an answer file in all kinds of matters and more (like all contacts from local outlook). I would be happy if someone has an answer for running a Web Service in local computer from a form screen in a browser that is running from a remote server like this diagram :
  15. Hi Ron i did has you suggested. procedure TSendMailFrm.btnAddFilesFromListClick(Sender: TObject); Var ThisName : String; begin // UniSession.AddJS('$.get("http://127.0.0.1:8989/GetMi", function( data ){' + // ' ajaxRequest(SendMailFrm.form, ["test"], { response : data }); '+ // ' }); '); ThisName := Self.Name; JustWriteToLog('btnAddFilesFromListClick - Self.Name = ' + ThisName); JustWriteToLog('Before UniSession.AddJS($.get("http://127.0.0.1:8989/GetMi"...'); UniSession.AddJS('$.get("http://127.0.0.1:8989/GetMi", function( data ){' + //' ajaxRequest(SendMailFrm.form, ["test"], { response : data }); '+ ' ajaxRequest(' + ThisName + '.form, ["test"], { response : data }); '+ ' }); '); JustWriteToLog('After UniSession.AddJS($.get("http://127.0.0.1:8989/GetMi"...'); end; procedure TSendMailFrm.UniFormAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin JustWriteToLog('EventName : ' + EventName); JustWriteToLog('Params : ' + Params.Text); if sameText(EventName, 'test') then edToList.Text:=Params.Values['response']; end; ++++++++++++++++++++++++++++ it work if the site (8077) and the server (8989) are in the same machine. if i run the site from the internet (before my router) and the serve is in my machine, the call to the function - done. but the ajax event on the form ajax event is not fire... so i can't get the response Any suggestion ?
  16. Hi Ron, i have problems working with Delphi + JS + Ajax + not pure Delphi 🥵 i now understand (or maybe not) that i have to use JS to call the WebService, because it must work in the client area and then move back the result data to the server to complete the task... i work on this since Friday and didnt get what i want... reading a lot of posts in unigui forms. when i create simple HTML : <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $.ajax({url: "http://localhost:8989/GetMi", success: function(result){ $("#div1").html(result); }}); }); }); </script> </head> <body> <div id="div1"><h2>Let jQuery AJAX Change This Text</h2></div> <button>Get External Content</button> </body> </html> and run it + click the button the #div1 caption get the result i need (really work). i can't figure out how to convert it to Delphi. in that code the function is done inside the JS and don't give back result. can you, please, help me understand this magic? Main.dfm Main.pas
  17. Hi Ron thanks for quick responce. please look at this. when i try to call NetHTTPRequest1.MethodString := 'Get'; NetHTTPRequest1.URL := 'http://localhost:8989/GetMI'; NetHTTPRequest1.Execute(); the browser can not call that webservice in the locan host. if a client work with my site )in is on Cloud), i want to run some service in each of there pc's do you use the same strategy dose CORS will help me to do this?
  18. Hi I write little web service (REST) work on port 8989. this web service opens outlook and get all the address books (regular and suggestion) + the first 1000 Emails detail from InBox (2-3 seconds) i write Web App with UniGui work on port 8077 there i have some form look like outlook, for sending message with attachments. i want the user to get the list of emails coming from the WebService. when i run the WebApp in my pc the web service is found and gives back the list i want. when i run the web app in the cloud and open with chrome or whatever i get error message i read about it in google and it seems i need to build a tunnel to my localhost... there are tools like ngRok, TunnelLocal..... but this is not good practice, it creates public IP so the"site" can call the web service in the local host by external IP. i dont think any client will agree on such solution.... does anyone did some connection like that from the web app to local host? if this will be solved, we could digitally sign with a token, talk to scanner, pad... and so on... a walk around is to put any flag (as file existing) in the file area and let the web service or http application write the data to some DB table and read the data on the web app i dont like this solution too. any one have idea?
×
×
  • Create New...