Tips from LCTU XPages Session

Mindwatering Incorporated

Author: Tripp W Black

Created: 08/21/2009 at 11:48 PM

 

Category:
Notes Developer Tips
XPages

Make a view XPage display a folder.
- XPages --> New XPage --> Name --> Add View Control by dragging to Design window pane --> Switch to Design tab to Source Tab.
Now, to switch the control to display a folder, find the <xp:dominoView> tag and change the viewName property to the alias name of the folder.

Note: In 8.5.1 the edit property panels will let you more easily set these via GUI, too.


Targeting Another Database by Name or Replica IDs
- Also inside the <xp:dominoView> is a property, databaseName. By default it is blank which means "this" database and could actually have been left out.
- To target a different database and view simply change the database name along with the view like you did in the first tip. Enter either the database file name or its replica ID.
- To specify a database on a different server using the "bang bang" syntax: joshua!!DbName.nsf.

Note: When you paste the replica ID, you can leave in or omit the colon in the ID.


How to Bind a Control to a Subform.
Same way as we did the folder. Just enter the subform's name.
- See wiki: http://www-10.lotus.com/ldd/ddwiki.nsf ("Using Subforms on XPages").


How to Manage Multiple Data Sources on One Page:
A XPage document looks like this on the URL:
http://myserver.mindwatering.local/DatabaseName.nsf/xpagenm.xsp?documentID=11111111111111111111111111113211&action=openDocument

To get it to display other documents defined (to map their documentID and action elements) on the XPage, we do a special source property, requestPrefixParameter.
This property is in the viewPanel control's properties. You basically populate that property with a unique variable and then reference it.
Example:
2 views, one categorized by topic, the other flat by title. Your requestPrefixParameters might be "cat" and "title" respectively. Now to send a parameter to one view specifically, you always add the prefix to all the normal parameters. Below is this concept using the "expandLevel" property.
http://myserver.mindwatering.local/DatabaseName.nsf/xpagenm.xsp?catexpandLevel=2&titleexpandLevel=1


How to Convert Data Presentation Formats in View Columns
Insert new columns in the viewPanel. (in an XPage, a view is basically a table, just like on the web). You then can write a formula or bind to a real view column. Afterwards, you just change the properties "Display type options for Date/Time" to different formats. So basically, you have on "real" view column with a date (or a document with a date field), and display on the XPage that date in a different format or multiple formats.
You can also do this in the source by updating the "dateStyle" property in the child <xp:convertDateTime> tag within the desired column's <xp:viewColumn> tag.
e.g. <xp:convertDateTime type="date" dateStyle="full">

You can also create a "customConverter". It has two converter options: getAsObject and getAsString. The documentation uses the phrases "browser to server" and "server to browser" which I find confusing. If your not going for the test, just remember that the getAsObject gives you a temporary "value" object,, and the getAsString let's you treat it as a string for @Formula string functions. The latter strikes me very similar to the NotesItem.Text property.
e.g.
getAsObject: return value;
getAsString: return @Trim(value);


How to Customize Data Sources on the URL
Lots of properties you can pass to either subset or give related documents:
searchMaxDocs (allows you to change number of results on a page. The GUI would auto update the next and page number links as searchMaxDocs is changed.)
parentID (useful only display kids of a selected document in another view above)
keys (this is similar to RestrictToCategory for "normal" view.)

You can also manipulate tags programmatically. Example, to have a document control above auto show it's child documents in a view control window below, you might use this code:
<xp:dominoView var="dominoView" viewName="MyViewName" parentID="#{javascript:dominoDoc.getNotesID()}">
(where dominoDoc is the var (variable) name of document above.)


JSON for XSP
You can have a view control which isn't bound to a view but to a "viewScope.dataList" and uses a repeat control. Typically you iterate through the JSON dataList elements.

The repeat control is more generic and doesn't help you. You have to build your own lists and design your own display for the data. It is great when you want to really warp the display of documents/views/whatever to a complicated custom look w/o the manual HTML passthru we all do, for example, with "normal" embedded views.

For example in the 8.5 Discussion template, the All docs "view" is a XPages Repeat because you can do so many in-line things in the All "view". The by Author "view" is a viewPanel.

Refreshing Part of a XPage
When you add a control, you can specify what get's refreshed. For example if you add a "pager" control, you'll get the "Previous | 1 | 2 | 3 | 4 | n | Next" pager control. In the pager's controls, you can choose whether it updates just its target (e.g. a view control) by checking (on) the Partial Refresh option. You can also change its style or create a custom one that even uses images instead of text.

The viewPanel control also does "Stateful Navigation". That means it remembers what the previous page looked liked. In other words, if you are on page 1 of the view's contents and expand a couple categories and then go to page 2 and then come back to page 1, you will find page 1 still has the same categories opened. They are remembered. That is Stateful Navigation.


Custom Controls
- Are custom, you give them properties and actions.
- One custom control tends to send data/action to another control.
- Have "Editable Areas" which are "Placeholders" called "Facets".
- Can be extended with "child" controls of itself if desired.


How to define default XPages for forms


How to do a JOIN !!!
See article by Nathan:
http://www.lotus911.com/nathan/escape.nsf/d6plinks/NTFN-7FRG79


Launching Applications/Databases to XPages
- In 8.5.0, XPages are only for the web browser.
- In 8.5.1, XPages can be run in the Notes Client.
- Update via the standard Application Properties Launch tab.


previous page