Here is an instance of a conversion problem when using the Domino Objects in JavaScript. I'm not sure if there are other similar conversion issues.
Bind an Edit Box to a request scope variable and set the data type to Number as shown below:
<xp:inputText id="inputText1" value="#{requestScope.notescolor}" defaultValue="0">
<xp:this.converter>
<xp:convertNumber type="number"></xp:convertNumber>
</xp:this.converter>
</xp:inputText>
Create code that uses the request scope variable as a parameter to a method that expects an integer such as setNotesColor in NotesColorObject. The following Button onclick event uses this method to set the value of the NotesColorObject, then sets its RGB values to request scope variables bound to other controls.
var color = session.createColorObject();
try {
color.setNotesColor(requestScope.notescolor);
requestScope.red = color.getRed().toFixed();
requestScope.green = color.getGreen().toFixed();
requestScope.blue = color.getBlue().toFixed();
requestScope.status = "Success";
} catch(e) {
requestScope.status = e.toString();
}
At run time, however, the call to setNotesColor causes an exception. The following message is delivered to the status request scope variable.
Method NotesColorObject.setNotesColor(java.lang.Long) not found, or illegal parameters
Specifying "Integer only" for the Number data type does not help. The value is taken as either a Long or a Double, and the method wants an Integer.
The work-around is to force a conversion, for example, with the top-level JavaScript function parseInt.
color.setNotesColor(parseInt(requestScope.notescolor, 10))
Alternatively you can use the Java method intValue.
color.setNotesColor(requestScope.notescolor.intValue())
You can use this popular hack to force the conversion.
color.setNotesColor(requestScope.notescolor * 1)
Finally you can use this @function.
color.setNotesColor(@Integer(requestScope.notescolor))