0

I have a sever side javascript from where I am calling Java Class to write the content to the file by reading a view entries.

I can show the loader in xpage front end that there is something happing behind. Now the java class iterates through the view entries, I wish to print the current status by showing the number of entries done in Java class, like 100 of 3000 entries are done and the done entry counts need to be updated dynamically in xpage frontend. To achieve this, I tried:

From the java class I save the counts of processed entries to a document in the database in the field entryCounter in the while loop and so on, then trying to access the same document field inside the xpage view, but here the count updates after completing the previous script call which is of Java Class Call, after the java class completes and the last server side script call ends the count gets updated, which is of no use, I want to show the real time counts while java class is processing the entries in the front ent to the user, because the server side event takes at least 5 min to complete the event process.

In between, server side event the other server side event don't gets fired to partial update the count component which I am trying get from the document saved by java class.

Is there any other way to dynamically update the count of processed view in java class?

In short I am trying dynamically update the count which is update in document from Java Class, but it is not getting updated if already a server side call is going, one that call completed the value for last count updates to the computed field.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ajit Hogade
  • 1,072
  • 9
  • 29

1 Answers1

1

IMHO you'd better use a different approach: a background agent, and some document known to both the agent and your XPage that contains the counter. A process that takes more than a few seconds should not be run in the foreground. Is that a feasible solution?

D.Bugger
  • 2,300
  • 15
  • 19
  • "A process that takes more than a few seconds should not be run in the foreground" I totally agree to this but my java class returns something which indicates the sucess and also error handlings if any in the front end.I dont know if agent return back to ssjs or not, – Ajit Hogade Aug 29 '20 at 07:45
  • 1
    In the intermediary document, you can let your agent write anything to any field, and save it as often as you like. The agent could set a field StartDate with a date/time, EndDate once it's finished, the number of documents handled, the errors it found, etc. All your XPage has to do is poll the intermediary document and display its data. – D.Bugger Aug 29 '20 at 13:21
  • Yes thats a better idea , but one more thing here you can suggest that after writing to document how it would be possible to continuously read the document for updated data fieilf without clicking and partial refreshing the components which we wish to update for the data written in document by agent to show real time progress of agent work in xpages. – Ajit Hogade Aug 30 '20 at 17:27
  • Can you read the document every 10 seconds or so, and display the actual value? If you really have to show more details, you could interpolate intermediate values. Why does it need such a high precision? Btw a much more complex solution would be to implement WebSockets, so you can send short messages from the server to the client without the client polling for them. Much more complex, as I said. – D.Bugger Aug 31 '20 at 22:58
  • Instead of an intermediary document, you could also develop a Log database, in which you log all activities, e.g. at the start, each transaction, at the end, so instead of watching a document you could watch a view in the Log database. – D.Bugger Sep 07 '20 at 09:32