Jump to content

Oliver Morsch

uniGUI Subscriber
  • Posts

    356
  • Joined

  • Last visited

  • Days Won

    18

Posts posted by Oliver Morsch

  1. Hi Oliver

     

    Many thanks for the reply.

    Unfortunately I'm not getting anything with this :

    Apanel.ClientEvents.ExtEvents.Add('OnAfterrender=function OnAfterrender(sender){document.getElementById(sender.body.id).className += " hoverpanel";}');

     

    This works fine in the same app using the in-place editor to add an event handler for the onAfterrender event of a design time created panel.

    OnAfterrender(sender){document.getElementById(sender.body.id).className += " hoverpanel";}');

     

    Any ideas ?

     

    Cheers

     

    This works for me (you must give the component a unique name):

    procedure TMainForm.UniButton4Click(Sender: TObject);
    var
      aPnl: TUniPanel;
    begin
      aPnl := TUniPanel.Create(self);
      aPnl.Left:= 30;
      aPnl.Top := 400;
      aPnl.Caption := 'Test';
      aPnl.Name := 'MyTestPanel';
      aPnl.ClientEvents.ExtEvents.Add('OnAfterrender=function OnAfterrender(sender){document.getElementById(sender.body.id).className += " hoverpanel";}');
      aPnl.Parent := self;
    end;
    
    
  2. Do I understand right: You want to "push" changes from the server to the client (without that the client has sent a request to get this)?

     

    In UniGui/Web you can only answer to a request from the client!

     

    You can use an UniTimer, use websockets (HTML5) or use "Long Polling" (see here)


  3. // UniForm1.script:

    function setMaskeventClosewindow(target) {
    var elements = document.body.getElementsByTagName('div');
    for (var i = 0; i < elements.length; i++) {
    if (elements[i].className.indexOf('mask') != -1) {
    elements[i].onclick = function() {target.close();};
    }
    }
    }


    // UniForm1.onShow:

    procedure TuniForm1.UniFormShow(Sender: TObject);
    begin
    UniSession.AddJS('setMaskeventClosewindow(' + self.WebForm.ExtWindow.JSName + ');');
    end;


    // call in MainForm:

    UniForm1.ShowModal;

     

  4. MessageDlg, ShowModal, ShowMessage don't "stop" the code execution in UniGui/WebMode, so you do:

     

    (1) You start a Modal Dialog and

    (2) give a (the initial !) result back.

    (3) After you click on OK/Cancel/Yes/No/...

    (4) the anonymous procedure (callback procedure) is called

     

    => (2) is before (3) and (4) so it can't contain the future result !!!

  5. Only inserts rows on a table

     

    Do you use

    (1) a database component such as TTable and use Table.append/insert

    OR

    (2) send SQL statements to the database server (insert into table ....)

     

    2nd should be better for your purpose.

     

    And how is the RAM usage on the server: How much it increases by a new user session and over time?

  6. If anyone has more ideas, please let me know.

     

    Instead of using a (global) function "choose_city(): integer" which returns an integer, I would use a (global) procedure "choose_city(DoAfterChooseCity: TDoAfterChooseCityProc)" which gets an anonymous procedure that contains the code to do after the city was choosen. And then call:

    choose_city(procedure(CityCode: Integer)
       begin
         //do this after the user has choosen a city...
       end);
    
    • Upvote 1
  7. I asume that you create the reports for the customer. I'm still looking for a way the

    user can create is own reports (like FastReport Designer) and store them in a

    database or as a file from within uniGui

    I think you are looking for this: 

     

    http://mobile.stimulsoft.com/Designer.aspx?reportname=SimpleList

     

    A alternative is that we created a Windwos .exe file containing the designer

    which the user has to start on his computer, design the report and storie

    it in the database.

    In reportmanager there is also an exe for creating reports standalone. But I think it is not usable by end users.

  8. Hi!

    I have developped a message server, so you can send "push" messages at any time from the server to the web client (using long polling). You can also send messages from a client to another client (with message server in the middle).

    The message server is a standalone app. You must run MsgSrv.exe and MsgCli.Exe (second is a uniGui project).

    I was using Delphi XE3 (with generics, class vars, ...), so i have included the .exe, because the message server does not compile in old delphi versions.

    For details see the commented screenshot.

    Regards
    Oliver
     

    post-147-0-22307200-1371351763_thumb.png

    MsgSrv.zip

     

    • Upvote 8
  9. This is very interesting. Please describe in detail or to share an example.

     

    I have to do and test a view things. After that I will share it.

    • Upvote 2
  10. Solved! I had not to change the UniGui response header. I had to change the XMLHttpRequest header (no custom headers) and the message server response header (add " Access-Control-Allow-Origin: * " there).

     

    Now I have "long polling" and so I can send "push messages" from UniGui server to all UniGui clients (browsers) and more. :D

  11. Hi!

     

    Is it possibble to add something to the http header (response)?

     

    I have an own standalone "message server" on another port and use XMLHttpRequest (in clientside javascript) to get/post messages.

    In IE10 it works properly. But in Chrome it returns with status 0 and I think this is because XSS security. So I want to try the "Content-Security-Policy" header.

     

    Regards

    Oliver

     

     

  12. Use "self.Components..." or just "Components..." instead of "UniFrame3.Components...".

     

    And never use a global var, because each user/session would use the same var. If needed use fields / properties.

  13. How to add a picture upload function?

     

    You can buy a file manager (file browser and uploader) on http://www.tinymce.com/index.php (but i think it needs PHP on server) or you can make your custom file browser (with UniGui):

     

    http://www.tinymce.com/wiki.php/Configuration3x:file_browser_callback

     

    http://www.tinymce.com/wiki.php/TinyMCE3x:How-to_implement_a_custom_file_browser

     

    There you can upload (TUniFileUpload) and/or browse your files to/on the server.

     

     

    I have added this to my script/init for including TinyMCE (adds a button to file/image dialog for calling my file browser):

    <script type="text/javascript">
    
      function myCustomFileBrowser(field_name, url, type, win) {
    
        //z-Order of tinyMCE popup dialog must be less than uniGui modal dialog: 
        document.getElementById('mceModalBlocker').style.zIndex = 7001;
        document.getElementById('mceModalBlocker').previousSibling.style.zIndex = 7002;
    
        //"save" fieldname for later update:
        TinyMceFileSrcFld = win.document.forms[0].elements[field_name];
    
        //Start my UniGui FileBrowser:
        ajaxRequest(MainForm.form, 'FileBrowser', [
          'URL=' + url,
          'Typ=' + type
        ]);  
        
      }
    
      ...  
      
      tinyMCE.init({
    
         ...
         
         file_browser_callback : "myCustomFileBrowser",          
    
         ...
    
      });
    
    </script>
    
    

    on MainForm i have this (on AjaxRequest start file browser form):

    procedure TMainForm.UniFormAjaxEvent(Sender: TComponent; EventName: string; Params: TStrings);
    begin
      if EventName = 'FileBrowser' then begin
        frmFileBrowser.URL := Params.Values['URL'];
        frmFileBrowser.Typ := Params.Values['Typ'];
        frmFileBrowser.ShowModal;
      end;
    end;
    
    

    on closing the file browser form i do this:

    procedure TfrmFileBrowser.UniFormClose(Sender: TObject; var Action: TCloseAction);
    begin
     if ModalResult = mrOK then begin
       UniSession.AddJS('TinyMceFileSrcFld.value = ' + QuotedStr(FileURL) + ';');
     end;
    end;
    

    In the future i plan to use Data URI scheme to include the image in the HTML itself.

  14. You can use "ajaxRequest(...)" in the javascript function "function Onmousemove(sender, x, y){...}" to send the values as parameter to the server and handle it there in delphi (see forum).

     

    But: The event Onmousemove you should handle in javascript, because there would be very much messages send to the server.

×
×
  • Create New...