Over the last couple of days there have been a few discussions about combining Compute on Page Load and Compute Dynamically. The full trails are below:

Both make good points and I have to say I’m glad I don’t have to make a decision on what changes, if any, should be made to Domino Designer as a result! Whether it’s a bug or a feature, I don’t have an opinion either way to be totally honest. If it’s allowed in the future, I’ll use it. At the moment, it’s something I’m happy to be aware of and work around.


And on that topic – working around it – I had another thought late last night (technically this morning!). As ever, it came from thinking about the problem from a different direction. It comes from an element of XPages probably under-used but extremelt powerful – dataContexts.


If you don’t know about dataContexts, read the part of the Mastering XPages book on them. They’re basically global variables that can be scoped to an XPage, a Custom Control or a Panel. Just the same as dominoDocument or dominoView datasources. This makes them very powerful, especially for values you plan on using multiple times on the page. Instead of the value being computed multiple times, it’s computed once and referenced via EL.


The code is pretty similar (again, I’m using a screenshot for ease because it’s SO simple:

New Binding Code

As with any other data elements, we have a var, which is how we reference it, and a value. Again, it’s computed on page load. But for computedField2 we can then use normal EL, so it’s #{username} and we don’t have to combine ${…} and #{…}.


The output now works.

New Binding Code Output

2 thoughts on “Combining $ and #: An Alternative Approach”

  1. Got this from Maire Kehoe…
    Another way is to use the runtime to change the string ‘#’ into a dynamic value when the page is loaded.
    For example…

    value=”STATIC – ${javascript:@Unique()} | DYNAMIC – ${‘#’}{javascript: @Unique()}”

    The main point to focus on is this part – ${‘#’} – which becomes becomes dynamic on page load.


    value=”Hello there ${javascript:@UserName()} how are you? Today is ${‘#’}{javascript: new Date()}.”

  2. @PaulWithers – thank you, much more elegant solution than mine – I had not put 2 and 2 together with regards to dataContexts before and that’s going to be very useful.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top