Posts Tagged: ‘JavaScript’

Tom Zeizels Blog: Domino Apps in Office 365? Ja!

18. Oktober 2018 Posted by Thomas Zeizel, IBM

Tom Zeizels Blog: Domino Apps in Office 365? Ja!  Viele Unternehmen nutzen heute die Office 365 Plattform von Microsoft. Dafür gibt es individuell die unterschiedlichsten Gründe und einiges macht unser Marktbegleiter sicher auch nicht schlecht. Aber man muss sich trotzdem die Frage stellen, ist „dort drüben“ wirklich alles Gold was glänzt, ist der Preis wirklich […]

Der Beitrag Tom Zeizels Blog: Domino Apps in Office 365? Ja! erschien zuerst auf DNUG.

IBM Domino 10 – die Meilensteine

9. Oktober 2018 Posted by Peter Schütt, IBM

Die Meilensteine zu IBM Domino V10 Heute hat Bob Schultz, General Manager IBM Collaboration & Talent Management, die neue Version 10 der Domino Familienprodukte angekündigt. Dazu gibt es eine Reihe von Meilensteinen – und der erste für Domino Version 10 ist bereits morgen am 10.10.2018! Hier die Übersicht: Domino V10.0, Notes V10.0, der Administrator Client, […]

Der Beitrag IBM Domino 10 – die Meilensteine erschien zuerst auf DNUG.

Tom Zeizels Blog: IBM Domino 10 ist da!

9. Oktober 2018 Posted by Thomas Zeizel, IBM

Tom Zeizels Blog: IBM Domino 10 ist da! Auf den Wies’n und Wasen heißt’s „O‘zapft is!“. So ist es jetzt auch mit der Version der IBM Domino Familien-Produkte. Bob Schultz, General Manager IBM Collaboration & Talent Solutions, hat soeben den weltweiten Startschuss für die Verfügbarkeit der neuen Version 10 von Frankfurt aus gegeben – vor […]

Der Beitrag Tom Zeizels Blog: IBM Domino 10 ist da! erschien zuerst auf DNUG.

EntwicklerCamp 2016: AngularJs

14. April 2016 Posted by Bernd Hort

EntwicklerCamp

Bei meinem zweiten Vortrag auf dem EntwicklerCamp habe ich das Thema AngularJS beleuchtet.

AngularJS-large.png

Das JavaScript-Framework erleichtert die Entwicklung von Anwendungen die primär im Browser ablaufen. Zum Austausch der Daten wird REST verwendet. Insofern war dieser Vortrag die ideale Ergänzung zum Vortrag REST Services in Domino.

Wie immer können die Folien und die Beispiel-Anwendung heruntergeladen werden.

 


EntwicklerCamp 2016: AngularJs

14. April 2016 Posted by Bernd Hort

EntwicklerCamp

Bei meinem zweiten Vortrag auf dem EntwicklerCamp habe ich das Thema AngularJS beleuchtet.

AngularJS-large.png

Das JavaScript-Framework erleichtert die Entwicklung von Anwendungen die primär im Browser ablaufen. Zum Austausch der Daten wird REST verwendet. Insofern war dieser Vortrag die ideale Ergänzung zum Vortrag REST Services in Domino.

Wie immer können die Folien und die Beispiel-Anwendung heruntergeladen werden.

 


EntwicklerCamp 2016: Javascript für Fortgeschrittene

13. April 2016 Posted by Thomas Bahn

EntwicklerCamp
Ich habe das Gefühl, dass die Konferenz von Jahr zu Jahr schneller vergeht. Vielleicht liegt es ja auch nur an den tollen Leuten und Gesprächen, dass mir das so vorkommt.
Sei es, wie es sei: Es war wieder großartig, inspirierend und lehrreich!

Die Präsentation zu meinem Vortrag in Track 2, Session 4: JavaScript für Fortgeschrittene:



EntwicklerCamp 2016: Javascript für Fortgeschrittene

13. April 2016 Posted by Thomas Bahn

EntwicklerCamp
Ich habe das Gefühl, dass die Konferenz von Jahr zu Jahr schneller vergeht. Vielleicht liegt es ja auch nur an den tollen Leuten und Gesprächen, dass mir das so vorkommt.
Sei es, wie es sei: Es war wieder großartig, inspirierend und lehrreich!

Die Präsentation zu meinem Vortrag in Track 2, Session 4: JavaScript für Fortgeschrittene:



Autosave when deleting attachments on an XPage

3. Dezember 2014 Posted by Christian Annawald

 

To download attachments in an application and also to be able to delete them, the FileDownload control is used on IBM Domino XPages. Unfortunately, this control comes with a little twist. If you click on the trash can icon to delete the attachment, it looks like the file is actually deleted. But the file is not finally deleted until the XPage is saved.

If you leave the XPage after the click on the trash can icon, without saving the document – after all, the attachment disappeared from the view, so why SHOULD you save the document anyway – and open it some time later again, the file is back.

 

Img. 1: Document including several attachments

 

Img. 2: Document after clicking the trash can icon of the last attachment

 

Img. 3: The last attachment is back again after leaving the document without saving and coming back to it afterwards

 

In order to execute the change, or rather the deletion, directly within the document, it is necessary to add the property setSave(true) to the event handler of the trash can icon. Unfortunately, you cannot do this within the Domino Designer. So a little programming work is needed.

Luckily I have found the appropriate code for most of this work in a discussion comment on stackoverflow by Sven Hasselbach: http://stackoverflow.com/questions/13101615/auto-save-doc-after-delete-of-attachment-in-file-download-control

Unfortunately, the original code always produced the following error when I used it with Notes 9:

X XPAGE ERROR: COM.XSP.IBM.ACTION.ACTIONGROUP INCOMPATIBLE WITH COM.IBM.XSP.ACTIONS.DELETEATTACHMENTSACTION

Therefore, I adjusted the source code, so that it works with Notes 8.5.3 and Notes 9 alike. To use it properly you only need to insert it into the BeforeRenderResponse event of the XPage.

 

<xp:this.beforeRenderResponse>

            <![CDATA[#{javascript:

            function overrideFileDownloadAction( fDownload ){

                        //Check whether the control exists or not

                        if( fDownload === null )

                           return;

                        //Call actual function

                        rekOverrideFileDownloadAction( fDownload, fDownload );

             }

/*

*This control iterates through all children of the FileDownload control

*and seeks the event handler

*/

            function rekOverrideFileDownloadAction( component:javax.faces.component.UIOutput,fDownload:com.ibm.xsp.component.UIFileDownload  ){

                        try{

                                   //Get children of the current element

                                   var children:java.util.List = component.getChildren();

                                   var it:java.util.Iterator = children.iterator();

                                   var curChild:javax.faces.component.UIOutput;

                                   //Loop over all children

                                               while( it.hasNext() ){

                                                         curChild = it.next();

                                                         if( typeof( curChild ) === 'com.ibm.xsp.component.xp.XspEventHandler' ){

                                                         //Event handler found

                                                         //set setSave to true

                                                         // to automatically save after the event

                                                           curChild.setSave(true);

                                               }

                                   //Event handler not found, therefore recursive call to investigate the children

                                   rekOverrideFileDownloadAction( curChild , fDownload );

                                               }

                        }catch(e){}   

            }

           

overrideFileDownloadAction( getComponent( 'IDFILEDOWNLOAD' ) );

//IDFILEDOWNLOAD = the ID of the FileDownload control

    }]]>

</xp:this.beforeRenderResponse>

 

If the above code is inserted into your XPage, the file is automatically saved after clicking on the trash can icon. The disadvantage of this is that it saves the complete document and not just delete the attachment. Therefore, you have to be careful to ensure that you have not previously changed the value of another field that should not be saved.

 

EntwicklerCamp 2014: JavaScript für Fortgeschrittene

19. März 2014 Posted by Thomas Bahn

EntwicklerCamp
Das EntwicklerCamp 2014 ist nun fast schon wieder vorbei.

Ich warte noch gespannt auf den Abschlussvortrag von Niklas Heidloff: Applikationsentwicklung mit IBM Collaboration Solutions. Heute morgen hat er angekündigt, es gehe um die 20 am häufigsten gestellten Fragen rund um die Entwicklung mit Notes und anderen ICS-Lösungen - heute, aber auch in Zukunft.

Meinen zweiten Vortrag, diesmal zum Thema JavaScript für Fortgeschrittene, habe ich eben gehalten. Und wie üblich sind hier die Folien zum "Noch-einmal-in-Ruhe-Nachlesen" für später:

Sicherheitslücke durch die Ausführung von Java-Applets in Notes

2. Mai 2013 Posted by Oliver Regelmann

IBM meldet den Fix für eine offenbar recht schwere Sicherheitslücke in den Notes-Clients 8.0 und höher:

The IBM Notes mail client accepts Java applet tags and JavaScript tags inside HTML emails,
making it possible to load Java applets and scripts from a remote location.

Heise formuliert das drastischer:

Notes/Domino von IBM hat ein riesiges Sicherheitsproblem, das jetzt mit einem Update beseitigt werden soll. Schon beim Öffnen einer E-Mail kann ein Notes-Nutzer seinen PC mit Spionage-Software infizieren.

Abhilfe schaffen kann man durch:

  • Filtern des Maileingangs auf entsprechende HTML-Tags, z.B. mit der GBS iQ.Suite.
  • Deaktivieren der Ausführung von Java-Applets und JavaScript in den Client-Vorgaben:
    image
  • Alternativ das Setzen dieser gleichbedeutenden notes.ini-Parameter am Client:

    EnableJavaApplets=0
    EnableLiveConnect=0
    EnableJavaScript=0

    Idealerweise verteilt man das per Desktop-Richtlinie.

  • oder Installation des Interim Fix 1, der inzwischen für die Versionen 8.5.3 FP4 und 9.0 zur Verfügung steht.

Eigentlich sollten korrekte ECL-Einstellungen am Client dafür sorgen, dass solcher Code nicht ausgeführt werden kann. Aber zumindest bei meinem 9.0 Client wurde dennoch das Applet ausgeführt, nicht aber das JavaScript. Testen kann man das mit dem Heise Security E-Mail-Check.

XPages onClick Partial-Refresh Bug bei Radiobuttons

22. Februar 2013 Posted by Bernd Hort

XPages

In XPages gibt es bei Radiobuttons im Zusammenhang mit einem Partial-Refresh bei einem onClick-Event einen ziemlich irreführenden Bug, wenn der Anwender auf das zugehörige Label klickt statt auf den Radiobutton selber.

Unmittelbar nach dem Anwender auf das Label geklickt hat, erscheint kurz die Änderung, um danach unmittelbar wieder den alten Stand anzuzeigen. Zur Verdeutlichung haben wir ein kleines Video vorbereitet.

Die Ursache für dieses Phänomen ist das Timing. Durch den Klick auf das Label, wird ein POST-Befehl für das Partial-Refresh ausgelöst. Zu diesem Zeitpunkt ist allerdings die Attributänderung des Radiobuttons noch nicht angekommen, so dass noch der alte Werte übertragen wird. Das ist auch der Grund warum magischer Weise über das Partial-Refresh der alte Stand wieder angezeigt wird.

Der Bug ist bei der IBM bekannt: LO71073: XPAGES RADIOBUTTON CLICK ON LABEL UNDONE BY PARTIAL REFRESH. Der aktuelle Status ist: "This APAR is closed as FIN. We have deferred the fix to a future release." Wobei FIN laut dem IBM Software Support Handbook für "der Fehler wird im nächsten Release gefixt" steht.

In der Zwischenzeit kann, wie so häufig, mit Hilfe von dojo Abhilfe geschaffen werden.

Dojo

Der folgende Code sollte im Client-Side JavaScript onClick-Event hinterlegt werden.

var e = arguments[0] || window.event;
e = dojo.fixEvent(e);
if (e.target.type != "radio") {
  e.preventDefault();
  dojo.query("input",e.target).forEach(function(inputNode){
    dojo.attr(inputNode,"checked",!(dojo.attr(inputNode,"checked")));
  });
}
return true;

Das Event wird zunächst in der Variable e gespeichert. Mit dojo.fixEvent(e) wird der Unterschied im Eventhandling zwischen IE und den standardkonformen Browsern nivelliert.

Wenn auf das Label geklickt wurde (e.target.type != "radio"), dann wird zunächst das Standardverhalten des Events unterbunden (e.preventDefault()). Anschließend wird das zugehörige Input-Feld gesucht und das Attribute auf "checked" gesetzt.

Der dojo.query-Befehl funktioniert, weil die XPages Laufzeitumgebung ein Radiobutton wie folgt realisiert:

<label>
  <input type="radio" value="Banana" name="view:_id1:radioGroup1">Banana
</label>

Das Input-Element ist also ein Kindelement des geklickten Labels. Somit kann über dojo.query("input", e.target) nach allen Input-Elementen unterhalb des  Elementes gesucht werden, auf den das Event ausgelöst wurde. In unserem Fall also das Label.

Es sollte übrigens bei Radiobuttons und Checkboxes immer das onClick-Event verwendet werden, weil der IE beim onChange-Event ebenfalls ein Timing-Problem hat. Wenn im IE das onChange-Event ausgelöst wird, ist die Attributänderung auch noch nicht vollzogen.

XPages: JQuery Gantt Module

16. September 2012 Posted by airwolf89

In the past weeks I was trying something new, at least new for me…

I realised that using jQuery in Xpages is a wonderful idea. Mark Roden has a nice blog with great things you can do with jQuery in XPages. You can find it here: Xomino Also check out his demo site: Xomino JQinX Demo

In one project I wanted to use a gantt chart. I want to write this article to show you how it’s done and warn you about the problems I had.

Let’s start.

To use jQuery you have to download it and integrate it in your database. Build your own version of jQuery here: JQuery Download It is the download page of JQuery UI, a set of many nice plugins and modules for jQuery. A version of the base jQuery is included. You can also configure a custom theme for your jQuery modules. It is on the right menu when you follow the link “design a custom theme

For the gantt chart I am using this module: Taitems JQuery Gantt Chart Module

So, now you have to integrate these files into your database. You can do this either via the resource category in the database, or via the PackageExplorer (it is an Eclipse View) I recommend using the package explorer, because you can manage your files more easily. Simply drag and drop your files and create some folders to organize them.

Now you have to load them into your application. You can do this easily via a theme with the following statement:

<resource>
<content-type>application/x-javascript</content-type>
<href>js/jquery-1.7.min.js</href>
</resource>

Or you load them directly into your code via the resource properties of the XPage/ Custom Control

<xp:script src="js/jquery-ui-1.8.23.custom.min.js" clientSide="true"/>

You have to do this for the jQuery base module, the UI module and the gantt module, also you have to load the CSS files.

First problem I had to face: The gantt module doesn’t work with every jQuery version. I was using jQuery 1.8.0. But when using this module, I had an error message which complained about some undefined variables (TypeError: m is undefined) Using the 1.7 version was a solution to this.

Now we can get started. On the page of the gantt module is an easy manual how to use this module. It is quite self explaining.

To implement a gantt chart, you only have to put in these few lines of code (client side of course)

<xp:scriptBlock id="scriptBlock1">
<xp:this.value>
// + "/ganttJSONBuilder?OpenAgent";
// + "/js/data.js";
jQuery( function() {
var dataPath = location.href.substring(0,
location.href.lastIndexOf('/') + 1)
+ "/ganttJSONBuilder?OpenAgent;

$(".gantt").gantt( {
source : dataPath
});
});]]>
<<!--xp:this.value>
<<!--xp:scriptBlock>

As data source the module uses JSON data. Use this site to validate your JSON data easily. The structure of your data is explained in the manual site of the module.

Be aware, the module expects a URL as data source. That means you can’t use server side Javascript in that scriptblock to generate the data source. So, we have two options on how to load the data into the module, either via a file which you can put into the WebContent folder in your database, or you call an agent. The agent is probably the better option because you sure want to load data dynamically.

Using an agent to achieve this is basically easy, you only have to write your JSON string into a variable and then you do this:

PrintWriter pw = getAgentOutput();
pw.println(output);

The difficulty of generating the JSON string itself depends on your data. In my case it was a simple project management, so some tasks, projects and editors. I used a view. I looped the entries and parsed the information into a JSON String.

There are some nice little things you should know when doing so.

The first line of your JSON string has to be the content type of the output, for JSON it is: Content-type: application/json; charset=utf-8\n
Also, it is very important that you use line breaks in the string, simply by using \n. If you aren’t doing that, your JSON string will not be properly interpreted and the module shows nothing but a nice grey bar.
Easily to overlook, but also important, in JSON you have to use a comma to separate your entries. Be sure you have no comma behind your last entry or parameter. It will result in a misinterpretion of the data.
The next important thing is, in the JSON data, you have to provide all entries defined in the manual. That means, if you forgot to write one of the parameters into the string, it is valid, but not recognized by the gantt module and isn’t doing anything. All of them need a value. providing nothing will have the same result: Nothing =)
I wanted to have my projects and tasks separated. In one line the project and then in the other lines the related tasks. This is possible by writing an extra entry to your JSON string, in which you only write the information about the project. When writing the tasks of the project, you probably don’t want to write the project in front of each task. If you think you can define an empty string for the name parameter of the JSON entry, you are wrong. The module needs a value of at least one character. Using an empty string results in not displaying the chart and some nice error messages. Using a space (” “) is the solution.
Also, you have to provide a start and end date for each entry. I wanted to have no duration for the project, so I didn’t provide the “from” and “to” parameter, it rewarded me with some other javascript errors. So I used the whole duration of the project for the project entry, it’s a good feature anyway.

A nice feature: You can use HTML in your JSON parameters, so, if you use
tags for example in your desc parameter and some formatting tags, you can make the mouseOver of the entries look more beautiful and put some more information into it.

If you think the styleClasses available for your entries in the chart (ganttRed, ganttGreen, ganttOrange) are not that beautiful, or you want to use some more, you can easily define some. There is a css file in the module. Looks like this:

.fn-gantt .ganttOrange {
background-color: #FCD29A;
}
.fn-gantt .ganttOrange .fn-label {
color: #714715 !important;
}

Copy those entries and do your own styles, the class at the end of the definition is recognized by the module, so you can use it directly in the “customClass” parameter of your JSON.

But there is one big problem when using this module. Above the chart, I have some buttons. I wanted to load different charts with those buttons. Easily done I thought, just firing a partial execute on the chart container to set another data source or something. But, nothing happens, in fact really nothing, not even an event which I could see in my FireBug. Some other buttons with only clientside code are working fine. All other buttons on the whole page are working fine, only those I have directly above my chart didn’t wanted to work. I haven’t figured out what’s the problem, if I find it, I will let you know.

Another problem is that the gantt chart is not working in the Notes Client. If I open the Xpage in my Notes client, the chart isn’t loaded, only a nice grey bar. Other jQuery modules are working fine, for example the accordion or flip is working, but not the module. If you want to use it in the NotesClient you should think about another solution… or wait until I find a solution for this problem =)

Another thing you should consider are loading times. The loading time is increasing dramatically proportional on how many entries you display (rowsPerPage parameter in the gantt function) and how many years they cover. If you want to display some tasks from a period of 10 years or more, you have to wait a bit. I tried a period of 30 years… not a good idea, my browser crashed… after about 5 minutes of loading.

So, I think that’s all I know about the module and how to use it. Despite all the small and big problems I have a nice application with some really nice gantt charts. If you are interested in such an application, you should visit this page (Cobalt Software GmbH), the new version should be available soon. Ok, sorry for the advertisement…

If you have any questions or solutions for my unsolved problems, the comment section is all yours =)

Hope it was useful for some of you.


Filed under: Notes & XPages Tagged: Chart, Cobalt Software GmbH, CSS, Datasource, Gantt, Javascript, JQuery, JSON, Mark Roden, Notes, Parameter, Plugin, Serverside Javascript, Taitem, Tools, Xomino, XPages, Xpages in NotesClient, XpInc

EntwicklerCamp 2012: JavaScript leicht gemacht

2. April 2012 Posted by Manuel Nientit

EntwicklerCamp
Wie auf dem EntwicklerCamp versprochen die Folien, Übungen und Musterlösungen zur Hands-On 1: JavaScript die ersten Schritten/leicht gemacht

Ich hatte viel Spaß, sowohl bei meiner Hands-On als auch in den anderen Sessions. Ich hoffe, dass ihr etwas mitnehmen konntet bzw. etwas mitnehmen könnt.


Ich freue mich schon auf das nächste Entwicklercamp vom 11.03. bis zum 13.03.2013!


XPages: Abfragen von radiobuttons mit javascript (clientseitig)

19. März 2012 Posted by Henning von Roon

Nicht selten sind es die kleinen Änderungen, die plötzlich mehr Zeit verschlingen als erwartet. 

Die Aufgabe: 
Wenn man bei einem Radiobutton einen neuen Wert auswählt, soll über eine Dialogbox nachgefragt werden, ob man dies wirklich ändern will. 
Überlegt es sich der Anwender noch einmal anders, so soll der neue Wert ignoriert werden.

Auf den ersten Blick sieht dies nach einer Aufgabe aus, die schnell erledigt ist. 
Doch wie so oft liegt die Tücke im Detail. 

Zunächst wartet bei den Events eine Überraschung: 
Der IE (8 & 9) ignoriert unter XPages beim RadioButton das onChangeEvent() 
Somit darf das onChangeEvent über das onClick Event nachgebildet werden.

Beim onClick-Event muss berücksichtigt werden, dass dieses bei der Auswahl eines neuen Wertes zweimal durchlaufen wird. 
Einmal mit dem alten und einmal mit dem neuen Wert. 

Den alten Wert der RadiobuttonGroup erhält man über folgenden Ausdruck: 


alterwert = '#{javascript:getComponent("radioGroup1").getValue();}';

Beim Versuch den neuen Wert zu ermitteln, wartet dann die nächste Überraschung. 
Einige empfehlen hier folgende Variante: 


  var elements = dojo.byId(id);
 for(i=0;i<elements.elements.length;i++) {
     if (elements[i].value == value) {
         elements[i].checked = true;
     }
 }

Kleiner Schönheitsfehler: Dies klappt zwar mit dem Firefox einwandfrei aber der IE (8 & 9) hält von dieser Variante nichts. Das Element daß der IE zurückgibt enthält schlichtweg keine Elemente durch die man sich durchhangeln könnte. 

Allerdings kann man sich recht elegant mit dojo.query den Wert des aktuell ausgewählten Radiobuttons holen: 


elements = dojo.query('INPUT[type=radio][name=#{id:radioGroup1}]:checked'); 
neuerWert = elements[0].value;

Das Deaktivieren eines Radiobuttons ist mit dojo.query nicht mehr als ein Einzeiler: 


dojo.query('INPUT[type=radio][name=#{id:radioGroup1}]:checked').forEach(function(n) {n.checked=false;});

Und auch das Setzen eines radiobuttons (z.B. den alten Wert) ist nicht mehr als eine Zeile 


dojo.query('INPUT[type=radio][name=#{id:radioGroup1}][value='+alterwert+']').forEach(function(n) {n.checked=true;});

Die dojo.query-Varianten funktionieren mit Firefox und mit dem IE. 

Nordic Coding: JavaScript

19. August 2011 Posted by Thomas Bahn

Auf der dritten Veranstaltung der Fachgruppe
Nordic
Coding
der DiWiSH
durfte ich heute einen Vortrag zum Thema "JavaScript  – The
World’s Most Misunderstood Programming Language
" (
Douglas
Crockford
, 2001) halten.

Hier sind die Folien zu der Präsentation,
so wie ich sie heute gehalten habe:


Ich empfehle aber, stattdessen die vollständige,
englischsprachige Präsentation (125 Seiten!) zu lesen, die ich auf der
UKLUG dieses Jahr gehalten habe. Mehr Seiten, mehr Fallen, mehr Tipps,
mehr Stoff: