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_borderINDIP: add visual indicator to type ahead

that’s how it looks:

field with type ahead waiting for input:
field with type ahead thinking
field with type ahead failure

this is the XML code of the field for the events:
<xp:eventHandler event=”onkeypress” submit=”false” id=”eventHandler2″>
<xp:this.script><![CDATA[if (event.keyCode==9 || event.keyCode==13){
removeVisual(‘view:_id1:inputText3’)
}else{
addVisual(‘view:_id1:inputText3’);
}]]></xp:this.script>
</xp:eventHandler>

<xp:eventHandler event=”onblur” submit=”false” id=”eventHandler3″>
<xp:this.script><![CDATA[removeVisual(‘view:_id1:inputText3’)]]></xp:this.script>
</xp:eventHandler>

and this is the style assigned to the field:
<xp:this.styleClass>
<![CDATA[#{javascript:if( currentDocument.isEditable()){ return ‘useTypeAhead’; }}]]>
</xp:this.styleClass>

this is needed in the CSS:
.useTypeAhead{
background: #fff url(“TypeAhead.gif”) no-repeat right;
}
.dijitValidationContainer{
width: 20px;
}
.dijitValidationContainer .dijitValidationIcon{
width: 20px;

this is needed in a CSJS library (cudos to Mark Roden and Sven Hasselbach)
function x$(idTag, param, jd){ //Updated 28 Feb 2012
// hardcoded
idTag=idTag.replace(/:/gi, “\:”)+(param ? param : “”);
return( jd==”d” ? “#”+idTag : $(“#”+idTag));
}

var inputField;

//addVisual function used to add a loading image to the screen and make it visible
//expected input string similar to view1_:id1_:viewPanel1
function addVisual(idTag){
var newImage=”url(‘loading.gif’)” //Change me for your server
inputField=dojo.query(x$(“widget_”+idTag, ” .dijitValidationIcon”, “d”))
inputField.style(“backgroundImage”, newImage);
inputField.style(“visibility”, “visible”);
inputField.style(“backgroundRepeat”, “no-repeat”);
inputField.style(“backgroundPosition”, “right”);
dojo.query(x$(“widget_”+idTag, ” .dijitValidationContainer”, “d”)).style(“display”, “block”)
inputField.attr(“value”,””)

}


//— hijack dojo XHR calls
//Thanks to Sven Hasselbach for this ajax intercept code
//
var typeAheadLoad;

dojo.addOnLoad( function(){

 /*** hijacking xhr request ***/
 if( !dojo._xhr )
    dojo._xhr = dojo.xhr;

 dojo.xhr = function(){
    try{
       var args = arguments[1];
       if( args[‘content’] ){
          var content = args[‘content’];
             if( content[‘$$ajaxmode’] ){
                if( content[‘$$ajaxmode’] == “typeahead” ){
               
                   /*** hook in load function ***/
                   typeAheadLoad = args[“load”];

                   /*** overwrite error function ***/
                //   args[“error”] = function(){
                 //     alert(‘Error raised!’)
                //   };
                   
                   /*** hijack load function ***/
                   args[“load”] = function(arguments){
                      /*** On Start ***/
                     // alert(“On Start!”);
                   
                      /*** call original function ***/
                      typeAheadLoad(arguments);
                   
                      /*** On Complete ***/
                  if (arguments.toLowerCase()==”<ul></ul>”){
                  var newImage=”url(‘typeAheadFailure.gif’)” //Change me for your server   
                  inputField.style(“backgroundImage”, newImage)   
                  }else{
                  inputField.style(“background”, “white”)
                  }
                   };
               }
           }
       }
    }catch(e){}
    dojo._xhr( arguments[0], arguments[1], arguments[2] );
 }
});


//removeVisual function used to remove the loading image from the screen and make it hidden
//expected input string similar to view1_:id1_:viewPanel1
function removeVisual(idTag){
var inputField=dojo.query(x$(“widget_”+idTag, ” .dijitValidationIcon”, “d”))
inputField.style(“backgroundImage”, “”)
inputField.style(“visibility”, “hidden”)
dojo.query(x$(“widget_”+idTag, ” .dijitValidationContainer”, “d”)).style(“display”, “none”)
}

//Checks to see if the visual icon is still running – if so then assume fail and kill it
function checkTimer(idTag){

dojo.query(x$(“widget_”+idTag, ” .dijitValidationContainer”, “d”)).style(“display”, “none”)

}

bookmark_borderINDIP: how to figure out the id of an element which triggered an event!

here’s the scenario:

We have what we call dynamic tables. It lets the user add as many rows as he requires. Really neat.
In some of the fields we use type ahead.

Recently I figured: it would be nice to see an indicator if the server is “thinking”… something like
I could do it easily via one specific field from which I knew it’s id …

But in those dynamic tables I have no clue on which field the event for type ahead was triggered….

until now:
Cudos to Paul Calhoun with his incredibly useful tips about CSJS (something I usually avoid as much as I can)

There I found the solution! You can call SERVER side JS from CLIENT side JS… isn’t that fantastic?

here’s how:
call the SSJS like this:
“#{javascript:<ServerSide JavaScript>}”

example to alert the id of an element via it’s event, in this case onFocus, which was triggered:
alert( “#{javascript:BackingBean.getElementId(this)}” )


For those ones interested what the getElementId does in my Java Bean:
UIInput input = (UIInput) handler.getParent();
return input.getClientId(FacesContext.getCurrentInstance());

Of course the UIInput could be changed to something more generic like UIComponent

stay tuned for my next blog which tells how I achieved proper visual indication

bookmark_borderINDIP: beware of the document.copytoDatabase method!

We had to merge two applications, so I created a background agent which copied all required documents to the “new” database. The customer tested and we set a due date for the real migration.
The night before actual migration I run an agent which deleted all “test” migration documents before the real agent to copy the documents run again!

Next morning I came to the office and thought: oh my dear. something went wrong! Only a few dozen documents had been copied, I thought!

So I rerun the agent again. First all seemed to be fine. Then a few hours later documents started disappearing. With no obvious reasons.

It took me about 3 hours to figure out that the method document.copyToDatabase would create the same UniversalId again!

So after having deleted the first round of “test” documents and recopied again at due date, the universalids of the documents had been in the deletion list of the LN db already. That’s why they started disappearing again after a while!

So I had to delete everything again to make sure, rerun the copy agent again but this time change the universalid.

Took me roughly a day to fix everything, something which normally would have taken about one hour.

bookmark_borderINDIP: How do you export data from an web application into Excel?

You could use POI to write an Excel file, but writing to a file with APIs is usually really slow.

MYYYYYYYYYYYYYYYYYY approach is blazingly faaaaaaaaaaaaaaaaaaaaast……..

In our company we are in the lucky situation that we have single-sign-on on the web towards our Domino servers. This is important for the following solution to export documents to work properly.

Steps:
1. Create some kind of “profile” document which defines the filters for the data the user wants to export
2. Create an agent which processes those filters from the profile document and outputs XML for all documents
Example XML:
<?xml version=”1.0″ encoding=”UTF-8″?>
<data xmlns:xs=”http://www.w3.org/2001/XMLSchema-instance”>

<document>
<processeddate xs:nil=”true”></processeddate>
<wfcurrentstate><![CDATA[70]]></wfcurrentstate>
<wfcurrentstatename><![CDATA[Returned for modification]]></wfcurrentstatename>
<timecreated>2013-10-08</timecreated>
<regionname><![CDATA[SOUTH AMERICA]]></regionname>
</document>
</data>

Important here is only the “xs:nil” attribute for “empty” fields, dates/numbers you can submit as is, text fields I advise to put into the <![CDATA[textvalue]]> format.
3. Import the XML via the URL of the web agent (eg. http://yourserver/yourpath/youragent?openagent) file into Excel via Data Import from other sources from XML data import.
Now the first time you do this you are have to go through some wizard actions done by Excel.
Once the XML map  has been created you can use that file over and over again (say as template). You simply need to refresh the data via the data tab in Excel.
My development workflow (to get this working start slow)
first only export some text fields
then try also empty fields (with the xs:nil) attribute
then continue with numbers and dates to see if it works
call the agent directly in the browser to check if the XML is properly formatted (Google Chrome will tell you so, maybe other browers as well)
then import that XML into Excel, ie. use the refresh button
I use to “log” the filters from the profile when the agent runs. My agent uses mostly FT Search to find the documents, only if more than 5000 are found it reverts to (if possible) view categories.
The “constructed” query is also logged. That way I can run the same query directly in the LN client to check for FT Query mistakes. As example I figured I need to put texts into double quotation marks to make queries, with filters consisting of more than one word, properly working.
The result is phantastic! I can export 5000 documents via VPN connection from my home office in about less than 30sec!
Questions? please don’t hesitate to write comments
otherwise enjoy!!!

bookmark_borderQUIND: Profile documents: sort of ;-)

I’m sure you also need sort of “profile documents” once in a while. Documents where a user can store some values he wants to use over and over again, in Web technology term thing of a “cookie”.

This is plain easy!

Simply open the xPage and as a Data source document id (red box) define a computed value like this:

Document ID code:
var doc:NotesDocument = database.getView(“lupUserProfiles”).getDocumentByKey(session.getEffectiveUserName(), true);
if( null != doc ){
return doc.getUniversalID();
}

that way the xPage will either be displayed empty (when no such “profile” document exists) or it will use the appropriate user profile it finds.

In the QuerySave (or somewhere else) you need to make sure to save the user name and have it in the view as sorted first column of course

QuerySave code:
try{
var doc:NotesDocument = docCurrent.getDocument();
var item:NotesItem = doc.replaceItemValue(“userName”, session.getEffectiveUserName())
item.setAuthors(true);
}catch(e){
// handle error
}

bookmark_borderYOUFEB: anyone else being mad about the copy&paste (via keyboard / not working in designer?

I am getting over and over mad that copy & paste is not working well at all in the LN designer especially when dealing with xPages stuff..

I add a template inheritance to a design element, select it, copy via <ctrl><c> and paste it onto another design element, either I get something pasted i copied long time ago, or nothing at all.

so I have to revert to right click copy and right click paste..

this annoys me a lot.. is it just me or anyone else facing the same issue?

bookmark_bordercreate golden text in Illustrator

  • create text you want to display in color, make it big and bold
  • select the font frame and then “ObjectExpand”
  • create several containers (squares) and copy color gradients from a gold bar into them, select them and use <i> to pick up a color from the gold bars and assign it to the container
  • create a new gradient having about 8 sections and fill with those colors repeatingly


    use the eye dropper tool to pick up the color from the containers to assign to the individual sections, keep <shift> pressed while doing so, otherwise the whole gradient will be filled with the picked up color
    fill gradient

    border/stroke gradient

  • apply the newly created gradient to text
  • use gradient tool <g> to “drag” the gradient into proper position: vertical/horizontal etc.
  • assign a stroke to the text and expand (ObjectExpand) only the stroke (deselect “fill”)
  • ungroup all twice, such that all the “borders” can be selected and applied the gradient fill
  • select the borders (strokes) and assign a nice “colored” gradient, see above

bookmark_borderError 500: your thoughts?

Developing xPages i’m sure you also have come across those nasty “Error 500” errors.

This bugs me right now. The error.log I get won’t help me at all.

Any ideas how to easier figure out the problem?

In my case the error.log simply states: “Unable to find component with ID xyz”.

Interestingly: the component IS visible.

I am a bit lost here: this happens in my xPage only when I copy the contents (some of them) to a new document which is then redirected to and opened in edit mode.
If I create the new document afresh all works as it should.
If I “copy all Items” to the new document then it also works fine.

any ideas?

bookmark_borderBUG in Lotus Notes applications: saving documents with private folders (not stored on desktop) and folder references enabled

Long time no see, but stay tuned, there will be more updates again soon regarding the xPages development from my side.

This week we have a very nasty bug. When people tried to save documents they got an “You are not authorised to perform that operation” error message.

After a while fiddling around we figured: We copied&pasted documents we could save the newly copied documents. So where was the difference? We used TeamStudio Delta to figure out differences between the two documents. It turned out mostly just the “Folder References” fields.

I googled and surely enough found this bug report: http://www-01.ibm.com/support/docview.wss?rs=463&uid=swg21099783

It basically states that users do get this error when folder references are enabled and the documents are stored in private folders which are not stored on the desktop.

maybe this information helps anyone out there to not “desperate” if faced with a similar issue.

yours

Michael