Jump to content

Roberto Nicchi

uniGUI Subscriber
  • Posts

    226
  • Joined

  • Last visited

Posts posted by Roberto Nicchi

  1. Hello,

    i'm wondering if is possible to set a TUniFormattedNumberEdit object so that it displays the number formatted with 2 decimals (for example) but it allows to insert more decimals (for example 4). Of course if more decimals than two are inserted than all the decimals must be visible. In other words the effect should be that same than the #0.00## display format string.

    If it's not possible you could add this as a request for future implementation. Myabe adding a new property to indicate the minimum decimals to format. In my example DecimalPrecision=4 and new property FormatPrecision=2

    Thanks

  2. 19 minutes ago, Sherzod said:

    Can you please clarify? 

    OK, consider a grid with some columns. When the focused cell is in a specific column we want to activate a button in a tool bar that allows to perform some task. For example open a list where is possible to select some value for the cell. In the oncolumnenter event we could check if the focused cell is in that column and, if so, setup the tool button (enable it, maybe change the button icon, and set the onclick event with a specific procedure). In the oncolumnexit we will disable the button.

    thanks.

  3. 5 hours ago, Roberto Nicchi said:

    Thanks a lot. I'll try it.

    I have just tryed and it seems to work fine. Thanks a lot.

    Another thing that would be usefull (anyway i don't need it immediately) are two grid events that allows to detect when the focus exit (oncolumnexit) or enter (oncolumnenter) a grid column.

    Thanks

  4. 5 hours ago, Sherzod said:

    Hello,

    Try this approach for now.

    1. 

    procedure TMainForm.UniFormCreate(Sender: TObject);
    begin
      with UniDBGrid1.JSInterface do
      begin
        JSAddListener('focusenter', 'function(me){ajaxRequest(me, "focusenter", [])}');
        JSAddListener('focusleave', 'function(me){ajaxRequest(me, "focusleave", [])}');
      end;
    end;

    2. 

    procedure TMainForm.UniDBGrid1AjaxEvent(Sender: TComponent; EventName: string;
      Params: TUniStrings);
    begin
      if EventName = 'focusenter' then
      begin
        //
      end
      else if EventName = 'focusleave' then
      begin
        //
      end;
    
    end;

    We will try to add this in the next builds.

    Thanks a lot. I'll try it.

  5. 1 hour ago, Sherzod said:

    Hello,

    What do you implying about these events?

    I would like to execute some Delphi code when the focus enter the grid and when exit. In detail the code active (entering) and deactivate (exiting) some components ...

    The events are present in the Tunidbgrid class but are not executed. I remeber there was some problem in unigui (probably related to the Sencha framework ?) and so was impossible to detect the focus entering/exiting the grid.

    Maybe the grid enhancements have/will remove this problem.

    thanks

  6. On 9/25/2021 at 2:39 AM, Norm said:

    Hi Roberto,

    Recording user  logins in the database and deleting the record when they logout is standard practice. However in order for this strategy to work well you also need to monitor user activity and kill sessions (trigger a logoff event) that are idle for too long. This would include those who have left their browser idling too long as well as those whose PC has gone off-line for whatever reason.

    There are several examples in this stream about how other developers monitor and shut down idle sessions.

    Just out of interest, what do you do if someone tries to log in with an ID that is already logged in?

    Hello. I simply block the login. Anyway the idea to close the session if the user has been inactive too long is good. I'll take a look to the threads provided by Sherzod. In particular this one:

     

  7. Hello,

     

    in my application each user login using an ID.

    i want to have only one session with a specific ID.

    In the app's database i have created a LOGIN table where a record is added when an user log into the application.

    When the user session is closed the record is of course removed.

    The problem is that if the user switch off the PC and keep the browser open it takes time to have the user id available again for application login. Is necessary to wait the session tinmeout (10 minutes).

    My solution is to reduce the session timeout to a short time (10 seconds instead of 10 minutes). Then in the main form of the app i have placed a timer that do something every few seconds. In this way there's not a timeout if the application is left untouched for a while.

    I'm wondering if this is the right way to go or for some reason i could have problems with solution ?

     

    thanks

    Roberto

  8. 1 hour ago, Roberto Nicchi said:

    Thanks, i have tryed with others web browser. I see the problem with Edge only. Tryed in two PC.

    Ok, delete from memory the thing that the problem is in two PC. I have had a wrong information. 

    The problem is anyway very odd.

    If i open the application using 127.0.0.1:8077 in Edge i see the problem with TuniURLFrame (blank pages). If i open the application with localhost:8077 the problem is not present.

    mmmm, evidently is not an unigui problem (i suppose). I would really happy to understand...

    I have tryed to disable the AV.

    thanks

  9. 4 hours ago, Frederick said:

    I do not have a fix for this as technical support did not provide a solution. I think that TUniPDFFrame is based on PDF.Js, a third-party solution, and there could be some coding issues with it.

    Currently, I use TUniURLFrame and the extra page does not appear. Maybe it is based on the web browser's internal engine and this problem does not occur.

    I like TUniPDFFrame but I could not wait.

    Thanks. I was using the TuniURLframe until today but i have changed because for some reason (using the Edge browser) some reports are visualized completly blank. The pages are created but no text or anything else is visible inside. The TUniPDFFrame doesn't have this problem but have others ...

  10. On 8/10/2021 at 1:57 PM, cyracks said:

    I will try to simplify. Program consists of only one empty Form and Form have declared only one event that is procedure UniFormKeyDown. So when Form is active and you enter anything on keyboard procedure UniFormKeyDown is called. Input variable is Key which is of type Word. So if you press letter A variable Key does not hold actual letter but numeric representation that is number 65. I would like to know how to convert numeric representation of written character to actual alfanumeric character, so how to convert 65 to letter A. 

    What is the correct way to convert numeric variable Key of type Word to actual String (by default UTF8).

    Hello. CHR function doesn't work for your needs ?

  11. 50 minutes ago, Roberto Nicchi said:

    I'll take a look to TThreadList class, thanks. Anyway what about if i use  TCriticalSection ? Is it ok ?

    example:

    type
      TUniServerModule = class(TUniGUIServerModule)

       procedure UniGUIServerModuleCreate(Sender: TObject);

       procedure UniGUIServerModuleDestroy(Sender: TObject);


      private
        { Private declarations }
        FTheStringList:TStringList;
        Fcs:TCriticalSection;

    public

       procedure AddSomethingToTheList(avalue:string);

    end;

    ...

    procedure TUniServerModule.UniGUIServerModuleCreate(Sender: TObject);
    begin
      Fcs:=TCriticalSection.Create;

      FUtenti:=TStringList.Create;

    end;

    procedure TUniServerModule.UniGUIServerModuleDestroy(Sender: TObject);
    begin
        FTheStringList:TStringList.Free;

        Fcs.Free;

    end;
     

    function TUniServerModule.AddSomeThingToTheList(avalue:string);
    begin
      Fcs.Acquire;
      try

        FTheStringList:TStringList.add(avalue);
      finally
        Fcs.Release;
      end;
    end;

    Ok i have found in the manual that my idea to use criticalsection is correct: http://www.unigui.com/doc/online_help/index.html?handling-concurrency.htm

    Anyway, for support the incoming Load Balance Server, i will remove this component and will save data into a database table.

  12. 1 hour ago, Abaksoft said:

    Hello Roberto,

    An other important  consideration :

    Maybe the next year, Unigui will have a load-balancing process.

    This mean that you will have two or many servers. This mean that your global variable value on the first server will not be known on other servers.

    One Solution :

    Use  DB table.

    You can read this from doc :

    "In future each uniGUI application can be divided into many several smaller processes to implement load-balancing and other advance feature. In this case any shared global variable in ServerModule will be visible to its owner process only not to the other processes which will server same application in a pool of processes. For this, it is recommended to keep such global variables in a database table instead of keeping them in memory."

    http://www.unigui.com/doc/online_help/index.html?handling-concurrency.htm

    Hello, i see. Yes, this is a thing i have to consider. Thanks.

  13. 2 hours ago, Pep said:

    Hi,

    TStringlist is not thread save. So would be better use a TThreadList class for such a scenario. 

    https://stackoverflow.com/questions/14425871/delphi-tlist-in-multithreading

    I also found this "TThreadStringList" class on the Internet (which I haven't tried):

    https://www.swissdelphicenter.ch/en/showcode.php?id=2167

     

    I'll take a look to TThreadList class, thanks. Anyway what about if i use  TCriticalSection ? Is it ok ?

    example:

    type
      TUniServerModule = class(TUniGUIServerModule)

       procedure UniGUIServerModuleCreate(Sender: TObject);

       procedure UniGUIServerModuleDestroy(Sender: TObject);


      private
        { Private declarations }
        FTheStringList:TStringList;
        Fcs:TCriticalSection;

    public

       procedure AddSomethingToTheList(avalue:string);

    end;

    ...

    procedure TUniServerModule.UniGUIServerModuleCreate(Sender: TObject);
    begin
      Fcs:=TCriticalSection.Create;

      FUtenti:=TStringList.Create;

    end;

    procedure TUniServerModule.UniGUIServerModuleDestroy(Sender: TObject);
    begin
        FTheStringList:TStringList.Free;

        Fcs.Free;

    end;
     

    function TUniServerModule.AddSomeThingToTheList(avalue:string);
    begin
      Fcs.Acquire;
      try

        FTheStringList:TStringList.add(avalue);
      finally
        Fcs.Release;
      end;
    end;

  14. 1 hour ago, Abaksoft said:

     

    As public (without property) = Not Safe  !

    You can read this from Online Documentation :

     

    "For example, one could define TUserInfo as a global variable in MainModule:

     unit MainModule;

     interface
    ...
    var
      UserInfo: TUserInfo;

     And access it in MainForm:

    procedure TMainForm.UniFormCreate(Sender: TObject);

    begin
      UniLabel1.Caption := UserInfo.Name + ' ' + UserInfo.Surname;
    end;

     

    Above code actually works during initial tests because, as long as there is only one active session, UserInfo will not be shared, and the application seems to behave correctly! However, as soon as multiple sessions logs in, the application starts to behave in a strange way."

     

    From :

    http://www.unigui.com/doc/online_help/index.html?general-design-concept.htm

     

    I never use public variable. Always properties to share variables beween Forms /Frames (on the current session).

    And to do best, i create a dedicated UniDataModule, only to put shared properties.

     

    http://forums.unigui.com/index.php?/topic/11974-global-variable/&do=findComment&comment=63879

     

    In the example i see that the variable UserInfo is created inside the unit but OUTSIDE the class definition. That way for sure can't work in a UNIGUI application because the variable is common to all session. But creating the variables (public) inside the mainmodule should be in my mind the same than using a property and a private variable. Probably there's a tecnical thing that i miss. Anyway i'll do as suggested and use properties. I guess it works also if the variable is a complex object. For example if i need a Tstringlist. The only thing i have to do more is create it in the oncreate event of the unimainmodule.

     

    TUniMainModule = class(TUniGUIMainModule)
    
    private
        { Private declarations }
        Fsl:TStringList;
    
      published
        property sl:TStringList read Fsl write Fsl;
    ...

    thanks

  15. 3 minutes ago, Abaksoft said:

     

    Hello,

    Your Code is Safe.

    There is no problem when  using  properties.

    in your example,  thevar  is visible for only the current session.

    (Read / Write)   =  No problem.

    If i had created the variable as public and didn't use the property, it wasn't correct ?

    thanks a lot.

  16. I have to share a TStringList between all sessions. Sessions needs to insert/delete items in the list.

    I have defined the Tstringlist object in the uniservermodule provate section and created some public procedure to update the list. The list is created in the oncreate event and destroyed in the ondestroy event of the uniservermodule.

    What's the right way to access the object in the session ?

    thanks

×
×
  • Create New...