0
votes

i have a strange problem.

I have a XPage with a repeat control where the data source is a view. This view has a filter by category name. In the XPage is a button with the following script:

doc = session.getCurrentDatabase().createDocument();            
doc.replaceItemValue("form", "myForm");
doc.replaceItemValue("docId", "myID");
doc.save();

The button makes a partial refresh on the repeat control, but always on the first time clicking on the button (after opening the XPage) does not refresh the repeater. After a second click on the button, i can see two new documents.

I have the same problem when i delete a document from the view, but in this case i get the following error message:

javax.faces.el.PropertyNotFoundException: Error testing property 'label' in bean of type null
Error testing property 'label' in bean of type null

Any ideas how to reload the repeat control will be better (without errors)?

1

1 Answers

2
votes

The problem is that you are creating the document on the backend, so the runtime isn't aware a new document is created, and is therefore dependent upon the indexer adding the document to the view before it will be added to the refresh, which usually happens after a slight delay, which is why after the next refresh, you see two documents. The way I have solved it in the past, which is a bit hacktastic to be sure, is to perform the refresh using a setTimeout() with a bout a 300-500 ms delay.

Hope this helps.