How to update xBrowse

User avatar
Otto
Posts: 6404
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 24 times
Been thanked: 2 times
Contact:

How to update xBrowse

Post by Otto »

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

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
Marc Venken
Posts: 1485
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: How to update xBrowse

Post by Marc Venken »

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.08 with Harbour
User avatar
Enrico Maria Giordano
Posts: 8756
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: How to update xBrowse

Post by Enrico Maria Giordano »

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

oBrw:bGotFocus = { || oBrw:Refresh() }


Not tested.

EMG
User avatar
Otto
Posts: 6404
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 24 times
Been thanked: 2 times
Contact:

Re: How to update xBrowse

Post by Otto »

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

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

//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

    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

    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


    <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: 6404
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 24 times
Been thanked: 2 times
Contact:

Re: How to update xBrowse

Post by Otto »

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
Marc Venken
Posts: 1485
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: How to update xBrowse

Post by Marc Venken »

Is it not so that afther the call to Mod.

WinExec ....

oBrw:setfocus()
oBrw:refresh()
Marc Venken
Using: FWH 23.08 with Harbour
User avatar
Otto
Posts: 6404
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 24 times
Been thanked: 2 times
Contact:

Re: How to update xBrowse

Post by Otto »

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
Marc Venken
Posts: 1485
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: How to update xBrowse

Post by Marc Venken »

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.08 with Harbour
User avatar
Otto
Posts: 6404
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 24 times
Been thanked: 2 times
Contact:

Re: How to update xBrowse

Post by Otto »

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
Enrico Maria Giordano
Posts: 8756
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: How to update xBrowse

Post by Enrico Maria Giordano »

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

EMG
User avatar
Otto
Posts: 6404
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 24 times
Been thanked: 2 times
Contact:

Re: How to update xBrowse

Post by Otto »

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
Marc Venken
Posts: 1485
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: How to update xBrowse

Post by Marc Venken »

Did you use a loop ?
Marc Venken
Using: FWH 23.08 with Harbour
User avatar
Otto
Posts: 6404
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 24 times
Been thanked: 2 times
Contact:

Re: How to update xBrowse

Post by Otto »

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: 6404
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 24 times
Been thanked: 2 times
Contact:

Re: How to update xBrowse

Post by Otto »

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

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
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: How to update xBrowse

Post by nageswaragunupudi »

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
Post Reply