bookmark_borderQUINDIP: intercept wrong/inexistent documentId

Hi

long time no post… but alas.. finally something I really like:

Have you ever had the situation, that you have a xPage which is workflow enabled, and you have (maybe) multiple servers? Some users might even use the LN client front-end on another server. The workflow sends out a mail telling the approver to approve.

Boom… the document did not yet replicate to the target server…

you do not want either of this message displayed:

what to do?

hmm.. I first tried with this, sorry, was not happy with it…

thing is: we use the same xpView for production and for archive, only the data source changes in the background. This will open the documents from the archive with such an URL:
http://server/db.nsf/%24%24OpenDominoDocument.xsp?databaseName=server!!otherDb.nsf&documentId=6496BA354B37544CC1257C680059C04B&action=openDocument

I could not get this to work..

So I had to figure out another way to intercept a “wrong” documentId.

Solution: use a phaselistener!!! (how to implement see here, kudos to Sven)

Now I only need to intercept the first phase in the JSF lifecycle, test if the supplied documentId exists and redirect:

event.getFacesContext().getExternalContext().redirect(“xpDocumentNotFound.xsp”);
event.getFacesContext().responseComplete();

I do some checks and then call redirect and responseComplete which executes immediately and does not continue with the other JSF phases

and the best thing: this is UNIVERSAL!!! I don’t need to implement it for all xPages I use!

bookmark_borderQUINDIP: need to run an agent as signer from an xPage?

we needed a possibility for users to “override” the workflow, ie. interfere even though they were not “authors” at the moment. The only way was to do with an agent running with more access rights.

solution was: us “sessionAsSigner”

this would not work:
var agent = currentDatabase.getAgent(“(agnXPageWFMoveToState60)”);
agent.runWithDocumentContext(currentDocument.getDocument() );
return “xsp-reopen”;

this did work (kudos to Sven Hasselbach):
var agent = sessionAsSigner.getCurrentDatabase().getAgent(“(agnXPageWFMoveToState60)”);
agent.runWithDocumentContext(currentDocument.getDocument() );
return “xsp-reopen”;

hope this helps some people to achieve similar things

bookmark_borderQUINDIP: dynamic “access controlled sections” ;-) in xPages

Some people faced the same problem than me: they wanted something like the “access controlled sections” in plain old LN development.
Mark Leusink
Russell Maher
Jeremy Hodge

None of the articles quite well didn’t explain how to set those ACLs dynamically..

I also tried to get set READER or EDITOR via something like:
return (condition to check) ? “READER” : “EDITOR”

but it wouldn’t work, especially not if in the condition the currentDocument was used. So what next?

I tried with a Bean, and it worked very smoothly. I put the code into the Bean constructor, the bean itself is a request scope bean, as (for whatever reason) I could not get view scope beans to work:

UIPanelEx panel = null;
ACL acl = new ACL();
ACLEntry aclEntry = new ACLEntry();
if (!(dominoDoc.getValue(“wfCurrentState”).equals(“1”) || dominoDoc.getValue(“wfCurrentState”).equals(“5”))) {
aclEntry.setRight(“READER”);
aclEntry.setType(“DEFAULT”);
aclEntry.setFullName(“*”);
acl.addEntry(aclEntry);

panel = (UIPanelEx) JSFConnector.findComponent(“panelRequestor”);
panel.setAcl(acl);
panel = (UIPanelEx) JSFConnector.findComponent(“panelDetails”);
panel.setAcl(acl);
panel = (UIPanelEx) JSFConnector.findComponent(“panelApprover”);
panel.setAcl(acl);
}


dominoDoc is the document source and the code prevents a few panels from being edited in all but in 2 workflow states (1, 5)

Neat!

bookmark_borderunQUINDIPping QUINDIP and other accronyms

according to Tim Tripcony (read the comment on this blog) quindip means confusion, I am now trying to unConfuse you about the confusion I created with my accronyms I use 
  • INDIP: INDispensabletIP (those ones which I deem very important in any xPages developers knowledge bag)
  • QUINDIP: QUickINDIP (those ones I deem quickly explained, 2min to read,  understand and implement)
  • FRULE: FRUstratedLearningExpierence (things I learned the hard way (shall I repeat how hard?), ie. it took me hours/days to get the hang of it and mostly in the end it was so obvious only I lacked some very basic knowledge in the first place)
  • CRYFH: CRYForHelp (when I have no clue anymore how to proceed and I need your input)
  • YOUFEB: YOUrFEedBack required (please gimme comments, ask questions what you want me to blog about etc)
  • DYHOP: DoYouHaveOtherProposals for accronyms? 😉
ups.. something very important I almost forgot…

let the game begin (provide your ideas in the comments): any idea what the anagram of in-mood is?

well.. a hint: in-mood is the anagram of the actual word. When I had my own company few years ago, I was so in (good) mood about stuff I was doing that time.. that I figured: great this will be my company name!

Unfortunately I cannot offer anything as a price to the winner besides maybe some special mentioning in a blog entry or my personal effort trying to help to solve an interesting xPage problem!

bookmark_borderQUINDIP: computed when composed fields in xPages

Did you ever wonder how you can “mimick” the cold computed when composed fields?

According to Brad Balassaitis there ain’t no equivalent in xPages.
According to Oliver Busse you can “fake” them anyway

Steps I would propose:

  • create a normal editable field and set it “disabled”
  • use this css to remove the border of the input: input[disabled]{border: 0px;}
  • use Olivers approach to add a value when the doc is first opened

<xp:actionGroup>

    <xp:setValue binding=”#{docCurrent.docRequestID}”

      value=”#{javascript:@Unique()}”>

        </xp:setValue>


            <xp:setValue binding=”#{docCurrent.docCreationDate}”

              value=”#{javascript:@Now()}”>

                </xp:setValue>

                  </xp:actionGroup>

                  It looks like this in the binding dialog:

                  I tested it, I think quite thoroughly: it works. I also tried to “change” the value via Inspector in the HTML source code.. after save&reload the old value was back.. so Notes seems to “know” which fields CAN and CANNOT be edited!! This is great news!
                  the fields are setup on creation of the document, they are saved to the document, they look like “static text”..