Setting SessionScope on XPage open - view

I have an Xpage with a view within it that displays search results that are based on the values of 6 fields on the xpage (These values are assigned to sessionscope variables when they selected, which drives the view selection when the search button is hit). This all works well, but what I'd like to change is that the view is empty when the xpage is opened initially (before any values are set).
Apologies for the simple question, but I haven't touched notes since 2006 and its changed a fair bit since then.
Running 8.5.2.

Each bean is instantiated when the scope is "initiated". For sessionScope this when you first open the site. For viewScope it is when you first open the page (will survive partial refreshes). And variables in these scope are just maps (i.e. beans) in that scope.
So to set an initial value you could either use a real bean - and just add whatever code you need in its constructor.
Or, if you want to use SSJS, you can add the check when loading a page (e.g. in the beforePageLoad event). If you are working in sessionScope you should check if a value is already set - and if not --> set it. In viewScope you would just initiate the variable.
And a word on scopes. If at all possible you should always prefer the "shorter" timed scope for performance/scalability purposes. See a little more about using sessionScope in my article about tuning XPages :-)
/John

Use viewScope instead sessionScope.
viewScope variables exist for the duration of the current XPage in current browser tab. If you open another XPage or open current XPage in another tab the values of viewScope variables are gone. That is what you need in your case.
sessionScope variables last for the duration of a user session in a browser across all browser tabs. That's why your current search values are set as default in another browser tab.

Related

Can I make something tab/window scoped in JSF?

Is it possible for JSF to store some information specific to a tab or window?
For example, let's say that I have a page with a datatable and the user can manipulate attributes of that table (column visibility, sort order, row selection, etc). The user clicks one of the entries to go to the entry's "view" page. Then they navigate back to the datatable page. They want their original datatable attributes set on that table.
But, if they open up that page in a different tab or window, they want to be able to manipulate attributes of that table on that tab independently. Therefore, session-scoped is not an option.
Perhaps I could use a flow-scoped bean to do this? Is that just abusing flow-scoped? For example, the bean would actually never terminate.
I'm also open to hearing about how bad an idea this is...so any alternative ideas would also be welcome.

Accessing the datasource of the XPage from a Custom Control

I guess that I am really missing something on the datasource in a custom control. When I create the custom control I have no idea what the name of the datasource on the XPage is going to be. I have added a custom property to the custom control to pass using the Type com.ibm.xsp.domino.model.DominoDocumentData and the Method Binding Editor, and this sort of seems to work if the Custom Control does not contain Custom Controls. At which point either I am getting lost or the XPage/Custom Control binding is getting lost.
Here is what I am trying to do I have created a Tab Table using the Extension Library and have placedd it on a cc. I have set up several tabs on it. Because the amount of information on each tab is pretty extensive I thought I would create a custom control for each tab. Then I ask the Yes/No question on almost every line I created a ccYN custom control, plus a couple of other ones as well because they can be reused and simple bound to a different fieldName that I have set up in the cc Properties. I see where others have said that if the datasource is defined for the XPage that it is available to all of the cc's, the method above seems to work for the first level but deeper than that leaves me or the XPage really confused. I have searched the internet/read Mastering Xpages but am not much further ahead.
It has been a long drawn out process but I think I have it now. On the Custom Control create a Property definition with a type of com.ibm.xsp.model.ModelDataSource with an edit type of String and call it something say ccDataSource. Then bind the the ccDataSource to the datasource of the XPage that contains it when it is know using SSJS so say it is myDataSource.
If the Custome Control is contained in a custome control and the datasource needs to be passed through another level the the binding is compositeData.ccDatasource or ?? whatever the outer datasource Property definition for the Data Source is.
There might be a cleaner way of doing this but I have not found it.
Not sure if you're still looking for an answer, but you can use the data source of "currentDocument" in a custom control. This assumes that the custom control is in a panel with one document data source, or in an XPage with one document data source.

CodeIgniter Persistent URL attach with every URL

In CI, I want to attach selected filter (in $_GET method)
to appear for every link I click.
This filter are persistent so is this filters selected in any page should be available for any other page in project.
For example, I selected dealerID, GroupId in one page, let's say dealer in page www.domain.com/dealers?dealerId=2&groupId=10 page, then if I click this another link named *www.domain.com/group*s the groups page should look like www.domain.com/groups?dealerId=2&groupId=10 that was selected in previous page.
And one more thing: I am using a main controller that will be inherited by all controllers for some reason.
Any help would be appreciated.
You could have one universal $data['filter'] variable that is going to preserve all variables that you need for filtering and than in view just add $filter at the end where you need it.
$data['filter'] can be collected/generated in constructor and defined by default.
It's little bit tricky solution i would rather use session to keep data of that kind and having "reset" button on page.

XPages - Bind Document Data Source in a embedded Custom Control

I created a custom control that is binded to a a Domino Document data source. I embedded it in a page so that I can display it in a Dojo dialog. It has 2 properties: dialogId and docId. The document data source's Document ID property is set to compositeData.docId. In the page, I set the docId property to a viewScope variable, that will be set when an entry in a view is clicked. What I want to accomplish is that the dialog will display the document that the current view entry (that was clicked) represents. But it seems that the compositeData.docId is not set on partial or even full refresh. Is there a way to do this that the custom control will be binded to the document? I need to have this binding so that I can easily do a server-side validation when I submit the dialog. Or if there is another way, can you also put it here? Thanks a lot!
set the datasource as the document, and then edit mode, then you have a place to compute the doc id, i usually compute the doc id to a viewScope, that i set when i click the item in the repeat control
More details here.
I would prefer the DocId to be transfered via the custom control parameters rather than a Scope variable. Using the Scope breaks the custom control design principle of being self contained. You can use the yourCC.PropertyMap to actually update a value, so the hand over of the parameter will work - of course your control then needs to be refreshed so the data source is recomputed. Hope that helps.

How do you switch backing bean objects in JSF?

Suppose I several tags, text input, radios, etc referencing one instance object. I would like to use a dropdown on that page to switch the references mentioned before to another instance of the object.
This part is pretty easy with change listener. However, the problem I have is the values currently displayed on the screen are getting set into the new, second instance.
I would like the current values to be stored in the current instance, and then the when the page refreshes I would like the new values to come from the new instance and be displayed on the screen.
Is there was way to do this? Does my question make any sense?
Grae
A value change listener is exactly the wrong tool for this, because it gets called before the values are set.
What you want is an action listener, which will get call after the values from the page are validated and set.

Resources