#XPages
Posts tagged #XPages · 21 posts
- DXL in XPages: It's createDxlExporter (not DXL), and Import Hinges on DocumentImportOption
In XPages you need to hand a document, or a whole view, to an external system as XML — or the reverse, feed a chunk of XML in and turn it into Notes documents. DXL (Domino XML) is Domino's native XML, and session has both directions built in: createDxlExporter() out, createDxlImporter() in. The first trap is the name — it's createDxlExporter, not the createDXLExporter (uppercase DXL) you'd instinctively type; wrong case and SSJS can't find the method. The second is on import: DocumentImportOption defaults to DXLIMPORTOPTION_CREATE (always create), so importing the same DXL twice makes two duplicate documents; for "update if it exists, create if not" you have to set REPLACE_ELSE_CREATE or UPDATE_ELSE_CREATE yourself. This covers export, import, that naming trap, and why you check the Log every time.
2026.11.22 - ACL in XPages: Check Access with queryAccess, Change It Only Through sessionAsSigner
Dealing with the ACL in XPages is usually two different jobs with different code. One is checking: is the logged-in user Editor or above, do they have a given role — to decide whether a button shows or a panel renders. That's just database.getCurrentAccessLevel(), queryAccess(name), and queryAccessRoles(name); no ACL object needed. The other is changing: an admin screen to adjust other people's access — that means getACL, edit, and save, but the web user is usually not a Manager and can't touch the ACL, so you go through sessionAsSigner to run as the design element's signer. This piece keeps the two apart: the access-checking shortcuts, comparing against the LEVEL constants, role gating, and why changing the ACL always routes through sessionAsSigner.
2026.11.20 - NotesName in XPages: getCommonUserName Saves a Step, Comparing Still Needs Normalizing
In XPages, to show the logged-in user's name many people write session.createName(session.getUserName()).getCommon(). You don't have to — session has getCommonUserName() to get the common name in one step, and getUserNameObject() hands you a NotesName object directly. That's where XPages is more convenient than back-end Java. But one thing XPages can't skip: comparing user names, or using OU for conditional visibility (rendered), still hits the "same person, canonical and abbreviated aren't equal" trap, and you still have to createName and normalize both sides. This covers the session name shortcuts, comparing and checking OU correctly in XPages, and which form to use when writing a name into a Readers field.
2026.11.17 - ViewEntry in XPages: Read the View with getColumnValues, Without Opening Each Document
In XPages you need to list a batch of data — a typeahead list, a chunk of JSON, a custom repeat. The columns you want to show are already laid out in some view. The reflex is to walk the view, getDocument on each row, and read the fields — but that opens every document, and a big view is slow. NotesViewEntry lets you read the index-level column values directly: getColumnValues returns each column's value for that row, and the whole walk can open zero documents. This covers getting a ViewEntry in XPages, reading column values, one confusing point (the collection from getAllEntries holds only document rows — category rows need a ViewNavigator), and that XPages, unlike Java, doesn't make you recycle.
2026.11.15 - Stream in XPages: Build a Download with getContents, and Set the Charset Yourself
In XPages you want the user to click a button and download a report file you generate on the spot, or read a file they just uploaded and parse it. The back-end NotesStream (session.createStream) is the tool for that. It has one method that's especially handy in XPages: getContents pours the stream's contents straight into a java.io.OutputStream — which is exactly what the HTTP response's output stream is — so you can stream the generated file to the browser without landing a temp file on disk first. This covers building a download with Stream, reading an uploaded file via fileUpload, writeText's no-line-ending default, and the charset-defaults-to-System trap (the deep dive on that lives in the Java Stream piece; here it's just the fix).
2026.11.12 - DocumentCollection in SSJS: stampAll Updates Them All, removeAll Deletes Them All
In SSJS a search, an FTSearch, or a view lookup by key hands you a NotesDocumentCollection. To do something to that pile of documents, the reflex is a getFirstDocument / getNextDocument loop; but the collection has batch operations of its own: stampAll sets one field to the same value across every document, and removeAll permanently deletes the whole batch — one line, no loop. Powerful, and removeAll especially will do exactly what you tell it, permanently. This covers getting and walking a collection in SSJS (including the Count-is-a-property-not-getCount gotcha), the stampAll / removeAll batch moves and their risks, combining collections with FTSearch and intersect/merge/subtract, and whose rights these run under.
2026.11.09 - In XPages the Database Is Free — the Question Is Whose Rights Opened It
LotusScript and Java both make you write a few lines to get a Database; in XPages SSJS, database is just there, pointing at the current NSF — you don't even call getDatabase. So the hard part of the Database in SSJS isn't how to get it, it's a question LS and Java rarely force on you: whose rights is this code running with? The user's? Or the XPage's signer's? This covers the database global, how to open other databases (session.getDatabase / getCurrentDatabase), and the session vs sessionAsSigner vs sessionAsSignerWithFullAccess rights model — when you have no choice but to run as the signer.
2026.11.06 - XPages Has Two Documents — Don't Edit the Wrong One
When you write document1 in XPages SSJS, you're holding the data-source wrapper (NotesXspDocument). But document1.getDocument() hands you a different object — the back-end NotesDocument. Both point at the same note, but they're two APIs: the wrapper uses getValue / setValue, the back end uses getItemValue / replaceItemValue, and each has its own save. This piece is about the back-end one: how to get it in SSJS, what it does (replaceItemValue / computeWithForm / save / remove / universalID), where the line between it and the wrapper sits, and why saving on both sides spawns a save-conflict document.
2026.11.04 - Three Kinds of Date in XPages — You Have to Know Which One You're Holding
The thing that bites you with dates in XPages SSJS isn't a method you can't call — it's not noticing that three different 'dates' are in play at once: the back-end NotesDateTime, the Java-layer java.util.Date, and JavaScript's own Date. What you read from a document is a NotesDateTime; what @Today hands you might be something else, and putting the wrong one in the wrong place throws or stores a bad value. This covers building a NotesDateTime in SSJS (session.createDateTime), converting between the three types (toJavaDate), the common methods (adjustDay / setNow / timeDifference / convertToZone), and the two classic traps — 'Today has no time' and '@Today isn't necessarily a NotesDateTime'.
2026.11.03 - XPages Performance: Why Computed Values Run Many Times per Submit
Drop a println in a computed value or a rendered formula, click a button once, and it runs five or six times — not a bug, but XPages running the whole JSF lifecycle on every submit, where a #{} (compute dynamically) value binding is re-evaluated every time it's read, adding up to several runs across the phases. This piece covers three knobs that cut that repetition: #{} (re-evaluated each time) vs ${} (computed once at load, static), rendered (in the tree, evaluated across phases) vs loaded (never built into the tree, skipped entirely), when to use each, and the ${} caveat.
2026.10.12 - What the true in document1.getDocument(true) Actually Does
In XPages SSJS you see both document1.getDocument() and document1.getDocument(true) everywhere, but what does that true (applyChanges) actually apply, when must you add it, and when is it just superstition? Getting the side wrong has real cost: omit it and you might save a document missing the values you just set in code; add it blindly and you don't really understand it. This piece sorts out getDocument() vs getDocument(true): true flushes the data source's pending changes (control input + programmatic setValue) into the backend document; in a normal submit the Update Model Values phase has already synced the on-screen values in, so it's usually redundant; you genuinely need true when you made programmatic changes or operate directly on the backend document. Plus the split with save() and getComponent().getValue().
2026.10.11 - After runOnServer in XPages the Document Is Still Stale — the Fix, and Using the contextDocument Instead of a Temp Doc
A common XPages SSJS pattern: create a temp document, fill in parameters, save, call agent.runOnServer(noteid), and the agent writes results back to that document on the server. Then you read it back — and get the values from before the agent ran. It's not a bug: the document object you're holding is an in-memory snapshot taken at load time, and the agent saved the note on disk in a separate execution, so your object never syncs. The fix is to recycle the stale object and getDocumentByID a fresh one. This covers the pattern, why you read stale values, the standard fix, using the form's own document data source (the contextDocument) instead of a temp doc, and the cleanest option — runWithDocumentContext, which passes an in-memory document to the agent and skips both the save and the re-fetch (at the cost of requiring the agent to Run as Web user).
2026.10.10 - The 12.0.2 'Documents Vanish Under a Sub-Category' Regression Family — Four KBs, Two notes.ini Parameters, Matched to Your Interface
After upgrading to 12.0.2, a multi-level categorized view shows only the topmost layer — the documents under the sub-category are gone. You search the symptom, find a KB, add its notes.ini parameter, and it 'did not work' — because this isn't one bug, it's a whole family: four official KBs, two different parameters. The client-side @PickList and embedded views use EnableExtendedFindByKey=0 (fixed in FP1); XPages uses DISABLE_REFIND_IN_READENTRIES=1 (fixed in FP3/14.0). This piece maps all four KBs into one table so you match your interface first, then set the right parameter.
2026.10.07 - XPages: Documents Don't Show When a Multi-Column Category's Next Column Is Also a Category — the 12.0.2 Regression
An XPages view categorized on multiple columns: you apply a filter, and where the next column is still a category, the screen shows the category but the documents under it disappear — in 12.0.2, though 12.0.1 works. It's an HCL-acknowledged regression (KB0102504 / SPR# MNIACMGKUV), introduced when 12.0.2 fixed another bug (SPR# PJONB7GRUL). The workaround is DISABLE_REFIND_IN_READENTRIES=1 in the server notes.ini; the real fix is 12.0.2 FP3 or 14.0. This covers the symptom, why it happens, the workaround and fix, and the wider family of 12.0.2 sub-category-display regressions (like the @PickList variant in KB0102042, which needs a different parameter and fix version) so you can match the right one.
2026.10.06 - Running @Formula from SSJS: session.evaluate — Its Vector Return, Limits, and Why It Can't Change a Document
You already have Formula logic — an @DbLookup, an @Name formatting call — and you don't want to rewrite it in SSJS. session.evaluate() runs a Formula string straight from SSJS and hands the result back. But it has sharp edges: it returns a java.util.Vector (not a scalar), field references need the document as a second argument, UI @functions (@Command/@Prompt/@PickList…) don't work in it, and it can't change a document — only compute a result. This covers the two signatures, the return and limits, and how to write the result back when you need to persist it.
2026.10.05 - XPages Managed Beans: Giving SSJS a Real Java Object You Use Like database
SSJS in a script library is fine as glue, but logic gets unwieldy fast — no real types, hard to test, and serialization headaches when you stash it in scope. A managed bean lets you declare a Java class in faces-config.xml, and it becomes a top-level variable in SSJS and EL that you use just like database or session — bean.method(), #{bean.prop}. This covers how to declare one (the name/class/scope elements), the three class requirements (no-arg constructor, get/set, Serializable), the scope lifecycle, and when logic should move out of SSJS into a bean.
2026.10.03 - partial refresh vs partial execution: the XPages JSF Lifecycle, and Why Refreshing One Area Still Recomputes the Whole Page
You click one button in XPages and a validator on a completely unrelated field blocks you — because by default the whole page runs a round of the JSF lifecycle, not just your button's area. XPages has two independent 'partial' knobs: partial refresh (refreshMode/refreshId) controls which HTML fragment goes back to the client; partial execution (execMode/execId) controls which components run the server-side lifecycle. This uses the six JSF phases to explain the difference, why partial refresh alone still recomputes the whole page on the server, and how partial execution scopes the server work down.
2026.10.01 - sessionAsSigner: Running XPages Code as the Signer — Who the Signer Is, and Where It Bites
XPages gives you three global session objects: session is the current user, sessionAsSigner is the XPage's signer, and sessionAsSignerWithFullAccess is the signer plus full access. Using it to let a user do what their ACL forbids (write a restricted DB, bypass Readers) is handy — but 'who counts as the signer' is decided per design element, so a script library uses its own signer, not the XPage's, and mixed signatures give inconsistent elevation. This covers the three identities, how the signer is determined, and the setConvertMime / full-access traps.
2026.09.28 - The Four XPages Scopes: How Long Each Lives, What to Put in Each, and What Blows Up
XPages has four scopes — requestScope, viewScope, sessionScope, applicationScope — with lifetimes from a single request to the whole application. Pick the wrong one and values vanish or leak across users; but the sharpest trap is that scopes get serialized to disk, so stuffing a NotesDocument, NotesView, or an SSJS function into one eventually throws NotSerializableException. This covers how long each scope lives, how unqualified names resolve tightest-first, what's safe to store, and why you keep a UNID or view name rather than the object.
2026.09.27 - XPages Save Conflicts: Why You Get One Even When You're the Only User
"Document has been saved by another user" — except no one else is touching the document, yet a save conflict shows up now and then anyway. This is an old XPages trap: mixing the dominoDocument data source's save with a back-end Document save on the same document makes Domino's conflict detection misfire and spawn a conflict document. Starting from the official conflict mechanism ($Revisions), it breaks down assono's classic reproduction and re-tests this 2013-era gotcha on both Domino 12.0.2 and 14.5.1.
2026.09.16 - Multi-Select Attachment Delete in XPages: Native Deletes One at a Time — Add 'Check Several, Delete on Save'
The XPages File Download control gives you one delete link per row — one attachment at a time — with no native 'check several, delete together.' Even a fully built production form lacks it. This piece first clears up something by testing: the native delete is actually 'commit on save' and well-behaved; then it adds multi-select batch delete with the same save-bounded official API (NotesXspDocument.removeAttachment), building a real check-mark, reversible, one-save implementation on a test server (Domino 12.0.2).
2026.09.13