Posts Tagged: ‘Errorhandling’

Quick-n-Dirty: Disable all validators at once

10. Februar 2013 Posted by Sven Hasselbach

In a larger project there are a lot of forms to fill in, each form has many fields with validators and converters. During the development of the workflow it was really helpful to disable all validators at once by using the setDisableValidators() method of the facesContext.

To control the behaviour I have added an URL parameter which is checked in the afterRestoreView event. If you open the XPage in the format

http://hostname/db.nsf/xPage.xsp?noValidators=true

all validators will be disabled. Here is a small example XPage:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

    <xp:this.afterRestoreView>
    <![CDATA[#{javascript:
        if( param.containsKey("noValidators") ){
            facesContext.setDisableValidators(true);
        }else{
            facesContext.setDisableValidators(false);
        }
    }]]>
    </xp:this.afterRestoreView>
    <xp:inputText id="inputText1" required="true" />
    <xp:br />
    <xp:button value="Send" id="buttonSend">
        <xp:eventHandler event="onclick" submit="true" 
           refreshMode="complete" immediate="false" save="true" />
    </xp:button>
    <xp:br />
    <xp:messages id="messages1" />

</xp:view>

This makes developers life easier!

Teamstudio Unplugged: SSJS & Error Messages

28. September 2012 Posted by Sven Hasselbach

Today I had to fight with a mysterious error message in a XPage application which is running on Teamstudio Unplugged:

SyntaxError: missing ; before statement

This IS the message. No more information. No stack trace. No library name. Nothing!

It was a hard piece of work to find the needle in the haystack: I used the synchronized keyword in a SSJS library. Hope in future Teamstudio will provide better error informations…

Quick-n-Dirty: Hijacking TypeAhead in CSJS

9. Dezember 2011 Posted by Sven Hasselbach

Matthias Nicklisch hat eine interessante Frage im XPages Forum gestellt, nachdem er festgestellt hat, dass im Designer zwar ein OnStart- / OnComplete-Event für die TypeAhead-Funktion angeboten wird, der Code aber als Deprecated angezeigt wird – und auf der XPage auch nicht funktioniert: Wie kann ein OnStart- / OnComplete-Event trotzdem verwendet werden?

Meine Idee dazu ist, den darunter liegenden dojo.xhr-Request zu hijacken, und auf diese Weise die Events zu erhalten. Dadurch lässt sich der Code bequem auf die jeweilige XPage einbetten, ohne das eine Manipulation der original Javascript-Dateien erfolgen muss.

Der folgender Code muß in einem CSJS-Scriptblock eingebettet werden. Dann erhält man für die TypeAhead-Funktion die Events, um zum Beispiel ein kleines “Loading”-Icon einzublenden, wenn die Daten vom Domino Server geladen werden.

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 ***/
                        alert("On Complete!")
                     };
                 }
             }
         }
      }catch(e){}
      dojo._xhr( arguments[0], arguments[1], arguments[2] );
   }
});

Java not found

18. Oktober 2011 Posted by Sven Hasselbach

Tippfehler werden von Domino (8.5.2) hart bestraft! Java kann nicht mehr gefunden werden!

Screenshot: Java Not Found

 

Die Hashmap muß natürlich “HashMap” heissen, und nicht “Hashmap”. Dann klappts auch…

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:scriptBlock id="scriptBlock1"
        value="#{javascript:
            var data:java.util.HashMap = new java.util.HashMap();}">
    </xp:scriptBlock>
</xp:view>