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



Mar 23, 2015, 8:23 PM
6 Posts
topic has been resolvedResolved

Scoped Variables lost on next page?

  • Category: Extension Library
  • Platform: All
  • Release: 9.0.1
  • Role: Developer
  • Tags: Scoped Variable issue,sessionScope
  • Replies: 3

Hi all

I'm transitioning a corporate web page  into a new xpage platform. It consists of a number of department-specific databases each with their separate ACL's with the old forms and docs, and one new xpage db front end presenting data from across the other db's read only. The content is regulations and resources for the rest of the organization to relate to.

The design consists of just a few custom controls which collects data sources dynamically via properties on the various department specific xpages. So like 30 xpages collecting data from separate db's utilizing the same handful of cc's

My scoped variable issue is related to my  cc_dataViewLocal . This dataView presents the documents from the corresponding views in the source db's. To let the user know their present location in the application I pull in the name of the current view  and display the name above the Data View as a headline on the DataView xpage:

<xp:text escape="true" id="computedField1"

styleClass="ksHeading2">

<xp:this.value><![CDATA[#{javascript:getComponent("dataView1").getData().getView()

}]]></xp:this.value>

</xp:text>

--

All documents from all databases are presented using the same documentDisplay xpage with a dynamic document data source. Thus this xpage does not have any properties but is referenced trough the data view xpage:

<xe:dataView id="dataView1" collapsibleCategory="false"

rows="50" style="font-size:8pt" rowStyle="font-size:8pt"

collapsibleDetail="true" pageName="/ks_documentDisplay.xsp"

var="rowHandle">

--

 When I open a document from the data view in documentDisplay.xsp I want the same headline/name of the original view displayed there as well.  To make that happen I try to catch the view name in a scoped variable in an afterPageLoad event in the data view xpage, to redisplay it on the documentDisplay xpage.

<xp:this.afterPageLoad>

<xp:setValue binding="#{sessionScope.ksView}">

<xp:this.value><![CDATA[#{javascript:getComponent("computedField1").value}]]></xp:this.value>

</xp:setValue>

</xp:this.afterPageLoad>

After all the view name is not part of the document data source, and I have no other handle to the parent view at this point as I can see.

--

When I display the scoped variable on the dataView xpage in a computed field it works fine:

<xp:text escape="true" id="computedField2"

styleClass="ksHeading1" value="#{sessionScope.ksView}">

However, when I try to display the same session variable in the documentDispay xpage using the same computed field coding it turns up empty. Like the sessionVariable is lost to the next xpage?

I started out with a viewScope, and tried both request and session with same results. What am I missing??

Any input greatly appreciated! Including workarounds but would like to get a grip on the scoped variables...:-)

Regards to all who read this somewhat long post and thanks in advance!

Vidar Solevag

</xp:text>

 

Resolved::

As is often is the case the solution was to do something else to get the same thing done...

What I found not to work: -Moving the event to onClientLoad didn't work it threw an exception "cannot handle". In addition my original approach afterPageLoad did't really work either as it didn't update properly as other dataViews were chosen via Navigator on the page. Also setting the variable via the "Set" option on the simpleAction list turned out to be a problem. I got several "Not allowed to set the value of a read only computed expression"

What I did that worked: -I set the value not by "Set"Simple action but by "Excecute script" and code sessionScope.ksView=context.getSubmittedValue(). This in the onClick event in Navigator that selects which Dataview to display On the DataView xpage Then the SessionScope remains alive all the way into the documentDisplay xpage and until a different Dataview is selected back in the Nav back on the DataView xpage.

Now using the same sessionScope as the viewName property on the xpage I also set the sessionScope initially on afterPageLoad to have a default value when page is first opened...

So thanks again, a lot of headbanging into the wall here but that's what you learn from I guess :-))

 

Mar 24, 2015, 3:01 AM
110 Posts
Is your next page retrieving info from different database?

Because from what I gather from the following pages:

http://xpageswiki.com/web/youatnotes/wiki-xpages.nsf/dx/Work_with_scoped_variables

http://www.intec.co.uk/sessions-logout-sessionscope-and-userscope/

http://www-10.lotus.com/ldd/ddwiki.nsf/dx/xpages-scoped-variables.htm

sessionScope is valid in the same application/database only. You can test using the XPages debug toolbar. I suggest you use the v3.01 if you got issue with the latest version.

http://www.openntf.org/main.nsf/project.xsp?r=project/XPage%20Debug%20Toolbar/releases/9008FE053C839B6386257C97003EEE1D

 

Mar 24, 2015, 5:09 PM
453 Posts
Something you might consider

In my application I have one "Main" database that contains all of the XPages design, while the actual data resides in a number of different databases organized by Application (in your case probably Department or ???) I have built an Application Scope Managed Bean that collects all the info about each application such as the DB replica ID for all the related DBs, plus a number of additional parameters. In my case these values don't change often so by loading them into an Application Scope Bean they are only loaded once and used by everyone. The application databases contain no XPage design only native Notes Forms/Views etc. I then set a SessionScope variable to the Application I'm using and and use that with my appProps bean to get the correct set of related info. I have never had any problem with the sessionScope variable for the Application Name because everything is run from the same "Main" database. My whole application is run from two XPages xpMain.xsp and xpMainInput.xsp and they just use a dynamic content control that selects which custom controls to load and where to get the data based on the application Name and a number of other sessionScope variables. So that appProps[sessionScope.ssApplication].appFilePath gets the file path for the application so I can use the same custom control for each application simply by using the appFilePath as a computed value in the dataSource.

Looking at your example I think something like this might solve your problem. I started with the XPages design in several different database but it became very difficult to maintain and debug. Now all the XPages Design and only the data that is used to control where stuff is resides in the main.nsf, everything else is in there own Notes only database. This might sound like a lot of work but I was able to build the JAVA Bean in a little over a day and had the whole application accessing it within another day or so, and I'm NOT a JAVA expert by any stretch of the imagination.  

Mar 24, 2015, 5:21 PM
298 Posts
Plus it makes is easier to use one theme...
If you are going to use something like Bootstrap or any other theme then having one nsf for your design makes it easy to put in all the supporting css, etc. you need. If you have more than one nsf for the design you have to repeat all these resources and themes.


Howard

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