How to update xBrowse

How to update xBrowse

Postby Otto » Fri Apr 23, 2021 7:30 am

Dear Mr. Rao.

Fivewin samples: barondlg.prg

I insert a new button, and from here, I open a mod harbour program to edit the selected database record.


Code: Select all  Expand view  RUN
function runMH(oBrw)
    nkdnr :=  ( oBrw:cAlias )->( RecNo() )
    WinExec("CMD /C start chrome --new-window --app=http://localhost/formular/index.prg?recnr=" + ALLTRIM(STR( nkdnr )) + " --window-position=1600,300  --window-size=980,700",0)
return nil


Then I change some fields in the MH APP and save the changes.

My problem is how I notify the xBrowse in barondlg.prg to paint the line and show the changes?

Best regards,
Otto

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6342
Joined: Fri Oct 07, 2005 7:07 pm

Re: How to update xBrowse

Postby Marc Venken » Fri Apr 23, 2021 7:50 am

Otto,

A Sollution could be to edit the database record directly outside the xbrowse (in your Mod program)
in stead of changing the Xbrowse values. A refresh of the xbrowse when comming back from Mod. would then also change the view of the browse

Unless there is a solution from Xbrowse itself
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1442
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: How to update xBrowse

Postby Enrico Maria Giordano » Fri Apr 23, 2021 8:20 am

Otto wrote:My problem is how I notify the xBrowse in barondlg.prg to paint the line and show the changes?


Try

Code: Select all  Expand view  RUN
oBrw:bGotFocus = { || oBrw:Refresh() }


Not tested.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How to update xBrowse

Postby Otto » Fri Apr 23, 2021 8:30 am

Hello Mark,

>A Sollution could be to edit the database record directly outside the xbrowse (in your Mod program)

That is exactly what I do.

From FIVEWIN

Code: Select all  Expand view  RUN
WinExec("CMD /C start chrome --new-window --app=http://localhost/formular/index.prg?recnr=" + ALLTRIM(STR( nkdnr )) )


I start a mod harbour APP and pass the record number with the request.

Then in mod harbour I read the argument from the URL

request: index.prg?recnr=999

Code: Select all  Expand view  RUN
//mod harbour
 function main
 
 
   cArgs := AP_Args()
   nRecno = VAL( SubStr( cArgs, 7 ) )


In mod harbour I open the customer.dbf and go to record number.
Code: Select all  Expand view  RUN
    use ( cdbf_file ) new ALIAS TMPDBF_FILE
   goto nRecno

then I fill a HASH and pass the HASH to the HTML part of the web page

Code: Select all  Expand view  RUN
    TEMPLATE PARAMS hTmp


In the HTML <form> I asign the HASH to a javascript object - this is very similar to harbour HASH.
Code: Select all  Expand view  RUN

    <script>
    var object=<?prg return hb_jsonEncode( hTmp, .T. )?>;
   
    document.getElementById("first").value = object[ "FIRST" ];
 



> A refresh of the xbrowse when comming back from Mod.
How can you notify xBrowse that you are "comming back" now.

Maybe a timer is a good solution. In practice, it is the same if you are working in a multiuser environment.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6342
Joined: Fri Oct 07, 2005 7:07 pm

Re: How to update xBrowse

Postby Otto » Fri Apr 23, 2021 8:35 am

Enrico,

I didn't found a way to open mod harbour with waitrun().
So if you close the mod harbour prg you are not sure that xbrowse gets focus.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6342
Joined: Fri Oct 07, 2005 7:07 pm

Re: How to update xBrowse

Postby Marc Venken » Fri Apr 23, 2021 9:27 am

Is it not so that afther the call to Mod.

WinExec ....

oBrw:setfocus()
oBrw:refresh()
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1442
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: How to update xBrowse

Postby Otto » Fri Apr 23, 2021 9:32 am

Mark,
Thank you.
But winexec does not wait till the mod harbour program ends.
That is the problem.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6342
Joined: Fri Oct 07, 2005 7:07 pm

Re: How to update xBrowse

Postby Marc Venken » Fri Apr 23, 2021 9:59 am

Ok,

Now I get it... Sorry

The Mod program will have some time to changes the input and FW is long passed it..

I would put FW in a permanent loop after calling MOD and looking for a field in the database like 'haschanged' to become true. The Mod program changes the values and finaly set the 'haschanged' set to true

Could work, but maybe there a finer techniques around ))
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1442
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: How to update xBrowse

Postby Otto » Fri Apr 23, 2021 11:50 am

Mark,
Thank you.

As refresh/paint is an essential part, I think it is worth thinking about.

We have the same situation with FWH.
You have two workstations. Both have open the client xBrowse.
Now one of the workstations changes something.

Until you do not set focus on the other workstation to the xBrowse you always see the old data.


The next question is how to handle concurrency changing.

I mean, this is the same problem in Fivewin multiuser environment.
Workstation 1 opens a client record makes changes but does not save.
In the meantime, another user made some changes.
If you have done your job well, you have to notify Workstation 1 that the record has changed.

I will look how to use a timer.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6342
Joined: Fri Oct 07, 2005 7:07 pm

Re: How to update xBrowse

Postby Enrico Maria Giordano » Fri Apr 23, 2021 12:13 pm

Yes, a timed refresh of the browse (each few seconds) looks like a good solution to me.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How to update xBrowse

Postby Otto » Fri Apr 23, 2021 8:16 pm

Hello friends,
I think this will become a nice sample for a hybrid FWH/MH program.
Now checkbox is updating fine.
Best regards,
Otto

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6342
Joined: Fri Oct 07, 2005 7:07 pm

Re: How to update xBrowse

Postby Marc Venken » Sat Apr 24, 2021 7:56 am

Did you use a loop ?
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1442
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: How to update xBrowse

Postby Otto » Sat Apr 24, 2021 9:16 am

Hello Mark,
No, not yet. First, I worked through all the different types of variables.
The dialog you see is mod harbour running in localhost.

Best regards,
Otto

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6342
Joined: Fri Oct 07, 2005 7:07 pm

Re: How to update xBrowse

Postby Otto » Sat Apr 24, 2021 1:31 pm

Dear Mr. Rao,
I see that there is some code in xBrowse which seems to me that you are working on an autorefresh().

Will you provide this option soon?

Best regards,
Otto


Code: Select all  Expand view  RUN
METHOD Display() CLASS TXBrowse

   local nSecs    := SECONDS()

   if !::lCreated
      return nil
   endif

   ::BeginPaint()
   ::Paint()
   ::EndPaint()

   ::nRefreshSecs := SECONDS() - nSecs
   if ::lProfiler
      FWLOG ::cTitle, ::nLen, ::nRefreshSecs
   endif

return 0
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6342
Joined: Fri Oct 07, 2005 7:07 pm

Re: How to update xBrowse

Postby nageswaragunupudi » Sat Apr 24, 2021 5:40 pm

1) The above code is not for any autorefresh.
If oBrw:lProfiler is set to .T., similar code in different parts of xbrowse logs time taken for different operations of xbrowse. This is useful for a programmer and also us to know which operations are consuming more time and to see if we can optimize.

2) Whenever XBrowse gets focus, it is automatically refreshed.
When you go to edit data in the mod-harbour dialog, xbrowse lost focus. When you close the mod-harbour dialog and return to the main xbrowse, the browse is refreshed and the changes are reflected there automatically.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 39 guests