Note that there are some explanatory texts on larger screens.

plurals
  1. PO#{javascript:viewScope.something} won't update after context.redirectToPage(...)
    text
    copied!<p>It is not long ago that I asked <a href="https://stackoverflow.com/questions/14379519/xpages-execute-context-redirecttopage-after-client-side-function">this question</a>, which was about updating a property bundle after a csjs-induced full refresh. I solved it with a URL-parameter that lead to a context.redirectToPage.</p> <p>Now I have an xPage with a jquery-based <a href="http://www.trirand.com/jqgridwiki/doku.php" rel="nofollow noreferrer">jqGrid</a>, which receives a string with JSON-data from the viewScope and displays that data in a table. When I edit a record in the grid and hit 'submit' the grid posts a parameter called 'oper' with values like 'edit', 'add', etc., for which I check in the beforePageLoad event of the page and then execute the save method of my managed bean. After this I update the viewScope variable with the new JSON-string and conduct a full refresh in the above mentioned manner which had worked before.</p> <pre><code>&lt;xp:this.beforePageLoad&gt;&lt;![CDATA[#{javascript: if (bccUser.isAdmin() &amp;&amp; param.containsKey('oper') &amp;&amp; param.get('oper').toString().length&gt;0) { bccGridDataHandler.saveGridDoc('RequestDummy','PersonRequestsDummy',param); } viewScope.put('jsonString',bccView.getViewColumnValue('PersonRequestsDummyJson',1)); print('jsonString in viewScope: '+viewScope.get('jsonString')); if (bccUser.isAdmin() &amp;&amp; param.containsKey('oper') &amp;&amp; param.get('oper').toString().length&gt;0) { var url = context.getUrl().toSiteRelativeString(context); if (url.indexOf('?')!=-1) { url += "&amp;doRefresh=true"; } else { url += "?doRefresh=true"; } print("redirecting to: "+url); context.redirectToPage(url); }}]]&gt; </code></pre> <p></p> <p>In the server console I can see the correct, updated JSON-string from the first print statement, so the save-method was successful and I have up-to-date data in my viewScope. The grid, however, does not show the updated data, neither does my test-div </p> <p><code>&lt;xp:text value="#{javascript:viewScope.get('jsonString')}" /&gt;</code></p> <p>I also tried a partial refresh on the grid and div after updating the viewScope, but the same happened. After a manual refresh of the page everything is fine again. So, what's happening here? I just want to pass a simple string to a control. Am I mistaken again about the xPages-Lifecycle and the order of events?</p> <p>Thanks in advance. Regards, Sarah</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload