XPage Dojo DateTextBox NotSerializableException - xpages

i have a xpage including a dojo DateTextBox. If i save the document, everything works well. But if i reopen the document, i get the following Exception:
Unexpected runtime error
The runtime has encountered an unexpected error.
Error source
Page Name:/OfferAccount.xsp
Exception
java.io.NotSerializableException: lotus.domino.local.DateTime
lotus.domino.local.DateTime
Stack Trace:
com.ibm.xsp.FacesExceptionEx: java.io.NotSerializableException: lotus.domino.local.DateTime
com.ibm.xsp.application.AbstractStateManager.saveSerializedView(AbstractStateManager.java:121)
com.ibm.xsp.application.StateManagerImpl.saveSerializedView(StateManagerImpl.java:152)
com.ibm.xsp.application.ViewHandlerExImpl._saveViewState(ViewHandlerExImpl.java:445)
com.ibm.xsp.application.ViewHandlerExImpl.saveViewState(ViewHandlerExImpl.java:439)
com.ibm.xsp.application.ViewHandlerExImpl._renderView(ViewHandlerExImpl.java:323)
com.ibm.xsp.application.ViewHandlerExImpl.renderView(ViewHandlerExImpl.java:335)
Here is the code of the DateTextBox in my xpage:
<xe:djDateTextBox
id="periodOfInsuranceBeginn" value="#{offerAccount.d_offerPolicyBegin}">
<xe:this.defaultValue><![CDATA[#{javascript:var today:NotesDateTime =
session.createDateTime(#Today());
return I18n.parseDate(today.getDateOnly());}]]></xe:this.defaultValue>
<xp:this.converter>
<xp:convertDateTime type="date" dateStyle="short">
</xp:convertDateTime>
</xp:this.converter>
</xe:djDateTextBox>
This Exception also occurs, if i use an EditBox of type dateTime.
Any ideas?
Thanks Mario

It seems that you use a Notes object (NotesDateTime) in your code. Notes objects are not serializable. Store them as a Java date instead and convert them back to a NotesDateTime object if you acces them.

Related

How to add Today() in DojoDateTime in XPages

I would like to add today functions anywhere in this component which sets the field as Today.
is it possible to do?
COMPONENT CODE:
<xp:inputText id="EvrakUlasimTarih" value="#{document1.EvrakUlasimTarih}"
valueChangeListener="#{changeRequestBean.valueChangeListener}" dojoType="dijit/form/DateTextBox" styleClass="fs-12 datetimeStyle">
<xp:dateTimeHelper id="dateTimeHelper2"> </xp:dateTimeHelper>
<xp:this.converter>
<xp:convertDateTime type="date" dateStyle="short">
</xp:convertDateTime>
</xp:this.converter>
</xp:inputText>
The component is open source, so yes, it's possible. I'm not aware of anyone who's extended the control to do that though. I suspect you would need to extend the renderer and add a function to jump to today's date in the JavaScript library incorporated by the renderer, but I may be over-simplifying it.
Can you set the default value of the inputText to #Today()? May be this set the component to the current date

setting database for xp:dominoDocument via properties file

I would like to set the location of a database for the xp:dominoDocument data Property via SSJS and a properties file:
<xp:this.data>
<xp:dominoDocument var="document1" action="openDocument"
formName="album - $f-album" computeWithForm="both"
concurrencyMode="force"
databaseName="#{javascript:datasource.getString('DB_FILEPATH')}">
<xp:this.documentId><![CDATA[#{javascript:context.getUrlParameter("UNID")}]]></xp:this.documentId>
</xp:dominoDocument>
</xp:this.data>
The datasource property contains e.g.
DB_FILEPATH=Bildr6Phase10Data.nsf
and is available via
<xp:this.resources>
<xp:bundle src="/datasource.properties" var="datasource"></xp:bundle>
</xp:this.resources>
The code above will cast the error:
com.ibm.xsp.exception.EvaluationExceptionEx: Error while executing JavaScript computed expression
Error while executing JavaScript computed expression
Script interpreter error, line=1, col=12: [ReferenceError] 'datasource' not found
However if I try:
<xp:text escape="true" id="computedField1"
value="#{javascript:datasource.getString('DB_FILEPATH')}">
</xp:text>
I get the value from the property.
What am I doing wrong?
Instead of a Computed Field, try logging datasource.getString('DB_FILEPATH') in beforePageLoad and beforeRenderResponse. Also log out a message in databaseName property. I would expect the databaseName property to be required when the component tree is first loaded. However, I would not be surprised if the resource string is loaded later.
An alternative may be to use xsp.properties file. There is code on how to retrieve a property from xsp.properties in XPages OpenLog Logger.

Custom Property in Repeat control stopped working

I have a strange bug that is reproducible but i cant find out whats causing it.
If i call this xpage i get the following error message:
Error while executing JavaScript computed expression
'fieldname' not found
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xe="http://www.ibm.com/xsp/coreex"
xmlns:xc="http://www.ibm.com/xsp/custom">
<xp:this.data>
<xp:dominoDocument var="Request"></xp:dominoDocument>
</xp:this.data>
<xp:repeat rows="999" var="fieldname">
<xp:this.value><![CDATA[#{javascript:"myfieldname"}]]></xp:this.value>
<xc:Widgets_Field
field_datasource="#{javascript:currentDocument}"
field_name="#{javascript:fieldname}">
</xc:Widgets_Field>
</xp:repeat>
I have tried to empty the cc but without any success. The only thing thats working is when i am either hardcoding the property field_name or when i set the repeat control to "create controls at page creation"
I am absolutely sure that code was working before but i cant find out whats causing the error message. Can you please give it a try and let me know if you also have the same problem.
Attached please see stack trace
com.ibm.xsp.exception.EvaluationExceptionEx: Error while executing JavaScript computed expression
com.ibm.xsp.binding.javascript.JavaScriptValueBinding.getValue(JavaScriptValueBinding.java:132)
com.ibm.xsp.page.compiled.ExpressionEvaluatorImpl.getBindingValue(ExpressionEvaluatorImpl.java:151)
xsp.Widgets_005fField$Widgets_005fFieldPage.createInputText4(Widgets_005fField.java:776)
xsp.Widgets_005fField$Widgets_005fFieldPage.createComponent(Widgets_005fField.java:142)
com.ibm.xsp.page.compiled.AbstractCompiledPage.buildComponent(AbstractCompiledPage.java:265)
com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildChildren(CompiledComponentBuilder.java:115)
com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildAll(CompiledComponentBuilder.java:84)
Within the custom control, if you use wrong binding that should be known at the page load, it throws such an error. For instance if your custom control contains a "loaded" attribute like:
<xp:text
loaded="${compositeData.field_name}">
That will throw such an error. That's why it works with "create controls at page creation" setting.
Update: If you are going to use dynamic binding within the custom control, see my answer at this question:
Dynamic Data Binding?

xpages decimal separator EditBox

I have a very very simple source code:
<xp:inputText id="inputText3"
value="#{document1.A}"
defaultValue="5.5" type="number">
<xp:this.converter>
<xp:convertNumber type="number">
</xp:convertNumber>
</xp:this.converter>
</xp:inputText>
If I use a European Browser (that use the comma separator for decimal number) only the first time (when load the page) I see the correct information on the field.
If I refresh (partialrefresh for example) the InputBox...I see 55
With USA Browser all work correctly (where the pound is a decimal separator)
I have try play with converter without success...
Have you some suggest to fix this problem?
Tnx a lot
I have solve my problem. The really problem was HTML5 attribute type=number that force with dot my number...
SO that I have created a custom converter and now work correctly:
<xp:inputText value="#{document1.valore}" id="valore1"
type="number" immediate="false" defaultValue="5.5">
<xp:this.converter>
<xp:customConverter
getAsString="#{javascript:value.toString()}">
<xp:this.getAsObject><![CDATA[#{javascript:parseFloat(value.replace(/,/g,"\."))}]]></xp:this.getAsObject>
</xp:customConverter>
</xp:this.converter>
</xp:inputText>
So work if you insert , or . in the inputtext
P.S. Chrome have the problem with the decimal value that don't render the value into the inputbox
I'm not sure if this is correct, but it sounds like the server is sending 5.5 to the browser. However, during the partial refresh, the European browser identifies the "." as a thousand separator so sends the value back to the server as 55, which is then written back to the underlying datasource as 55 and passed back to the browser as 55.
You might be able to confirm that by checking the post data from the browser or adding a custom validator that just prints the submittedValue for the component. It would need to be a validator or converter, in order to run in the Process Validations phase, and so before the value is converted and written back to the field. Server-side 5.5 should be dealt with the same way regardless of the browser.

XPages Extension Library: namepicker not working

Is there any issue with namepicker of Extension Library version 9.0.0.v00_01_20130415-0518?
It does not display popup window for address book, here is my code:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex">
<xp:panel>
<xp:panel>
<xe:namePicker id="namePicker1" for="djName">
<xe:this.dataProvider>
<xe:dominoNABNamePicker addressBookDb="names.nsf" addressBookSel="all">
</xe:dominoNABNamePicker>
</xe:this.dataProvider>
</xe:namePicker>
<xp:br></xp:br>
<xp:br></xp:br>
<xe:djextNameTextBox id="djName" multipleSeparator="," multipleTrim="true">
</xe:djextNameTextBox>
</xp:panel>
</xp:panel>
</xp:view>
And also, I have manager's rights on names.nsf database.
Edit:
strange behavior! I change <xe:djextNameTextBox control to <xp:inputText and its works fine. How to debug xe:djextNameTextBox control to figure out the problem?
Edit 2:
Following error display when xsp page load:
Uncaught Error: Could not load 'dijit.form._FormValueWidget'; last tried '../dijit/form/_FormValueWidget.js' dojo.js:14
dojo._loadModule.dojo.require dojo.js:14
(anonymous function) #Fi&#Ez&#EOf&#Ek.js:107
Uncaught Error: Could not load class 'extlib.dijit.NameTextBox #Fi&#Ez&#EOf&#Ek.js:20
(anonymous function) #Fi&#Ez&#EOf&#Ek.js:20
$DBrH_ dojo.js:14
$DBpd_ #Fi&#Ez&#EOf&#Ek.js:20
$DBpe_ #Fi&#Ez&#EOf&#Ek.js:20
_4c #Fi&#Ez&#EOf&#Ek.js:20
dojo.loaded dojo.js:14
dojo._callLoaded dojo.js:14
dojo._modulesLoaded dojo.js:14
dojo._loadInit
After page load, when I click on name picker button another error display:
Uncaught TypeError: Object # has no method 'selectValue'
Your xe:djextNameTextBox control is not bound to a value. Try binding to e.g. a viewScope variable or a field on a document datasource:
<xe:djextNameTextBox id="djName" value="#{viewScope.nameField}" multipleSeparator="," multipleTrim="true">
</xe:djextNameTextBox>
Notes/Domino 9 now comes with Extension Library built in as standard. You do not need to install the extlib from OpenNTF.
I tested your source code in a default install of Notes 9. I get the following output:
Clicking the icon gets me this (I added the Admin + clicked OK).
The output of the page is now this:
My observation are below:
I uninstall Extension Library version 9.0.0.v00_01_20130415-0518 and upgrade to 900v00_02.20130515-2200, but the problem did not resolved. Then I install 8.5.3.20130315-0724 after uninstalling version 900v00_02.20130515-2200 and it works.
One more thing is that, at first after installing version 8.5.3.20130315-0724 it did not work in chrome browser (which was already opened on my laptop) then I open firefox and surprisingly it shows the address book, I mean that xe:djextNameTextBox control works with name picker control as expected. Then I switch to Chrome and clear all the history and reload the page .....!!! yes its work here too.
I repeat all the above stuff for Extension Library version 9.0.0.v00_01_20130415-0518 and Extension Library version 9.0.0.v00_01_20130415-2200 but xe:djextNameTextBox control not working with that versions.
-mak

Resources