This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Jun 28, 2011, 8:11 PM
13 Posts

Detect refresh event on a view

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags: view,events
  • Replies: 3
I have an xpage with three parts: a document at the top, a search input field in the middle, and a view in at the bottom.
 
I update the view dynamically as the user types in the search input field. If they click on a document, I display the document at the top of the Xpage.

This all works great.
 
I want to add one thing.

When the user is typing (and the view is updating dynamically) if there is only one document in the view I want to automatically update the document at the top of the page (just as if they selected the document). It seems like it should be easy, but I can't get it to work.
 
I can put a field in the viewpanel and put a field in there that puts the number of docs in the view (after searching). I use 
 
getComponent("viewPanel1").getRowCount();
 
What I can't figure out is how to write something that detects that I only have 1 in that field, adds the DocID to a viewScope variable and then does  partial refresh on the top part of the Xpage.

Any help would be greatly appreciated.
 
Bryan
Jun 30, 2011, 4:24 PM
129 Posts
Re: Detect refresh event on a view
If I remember correctly, you can use getEntryCount to get the number of "filtered rows".
 
Not sure, but you could maybe use context.redirectToPage( '/nameOfXPage.xsp?action=openDocument&documentId=' + entry.getUniversalID() )  when there is only one row. If that doesn't work (not sure if partial updates can result in redirect), you could have a xp:scriptBlock that only shows when there is one row. document.location.href = "#{javascript:codeToComputeURL}".
Jul 1, 2011, 4:44 PM
13 Posts
Re: Detect refresh event on a view
Tommy, thanks for your post. 
 
I looked at your suggestions but am not sure if they really address the problem. Maybe I am not understanding or explaining.
 
I am able to get a handle on the number of documents in the view. The crux of the issue is how to fire a partial refresh on the data panel at the top of the form after the view is recomputed. The events go like this:  
 
The Xpage loads. The top 1/3 is a picture of the CEO and data. 
The middle 1/3 is a search field. 
The bottom third is a view. 
 
The user types something into the search field, which fires a partial refresh on the view and the view is subsetted.  
 
The user an at any time click on the data in column one (persons name) and that fires a partial refresh on the data panel, loading the person's picture and data.  
 
If the user continues to type and gets down to one element in the view I want to grab that UNID of the document, which I can do, and then fire the partial update on the data panel. 
 
But there are no events for a view? Can I add an event? There is a postopenView "event" in the data properties of the view. I got a long way coding that - got everything I need EXCEPT I can't fire a partial refresh because I am in SSJS.  
 
I am somewhat new to Xpages so sorry if this is actually easy or I misunderstood you. Any suggestions would be much appreciated!!! 
 
Bryan 
Jul 13, 2011, 4:23 PM
129 Posts
Re: Detect refresh event on a view
Sorry for the late reply. Forgot all about it.
 
The only way I think you can achieve this is if the search field refreshes both the view and the data panel.
 
In the beforeRenderResponse event (and maybe in the partial refresh of the field), you can check if there is only one document in the view / act accordingly. 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal