Custom Property in Repeat control stopped working - xpages

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?

Related

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.

XPage is blank in Webbrowser

After a new Domino Designer Installation (newest Trail) I created a simple, simple Xpage and try to open it in a Browser (FF). The Xpage was loaded but has not HTML code. In other words its a blank page.
What did I do wrong ?
Update :
This is the XPage source code , very simple
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" rendered="true">
Hello World
<xp:br></xp:br>
<xp:comboBox id="comboBox1" style="width:82.0px">
<xp:selectItem itemLabel="Eis"></xp:selectItem>
</xp:comboBox>
</xp:view>
UPDATE :
The solution to my question was answered by stwissel givving a hint to the viewport. Indeed the viewport 80 was blocked by another program. Can' remember which one. Then I changed the viewport under preferences->Domino Designer -> Web View Port to 8080 and it works. But I doubt that this is a permanent solution.
Check if "Build automatically" is turned off. If so (recommended setting btw) just build the project manually after every change you made.
Also check if the page has the "rendered" property set to "false". This will result in an empty response though you won't get an error message.
I answer my question myself, because there are different behaviours with FireFox and Edge Browser. In another try with Edge the browser shows a 404 Eror, while FireFox did not do that. So the question finally has to be why is there a 404 Error coming up
Have you tried cleaning the project? Project >>> Clean (from the top toolbar in designer)

Using design definition for computed properties

I cant find a solution for this problem. I am using design definitions for almost all my controls.
They are working fine the only problem i have is that if i am computing one of the properties i cant use the property anymore in the design definition. It will create a text in red and the xpages will prompt some error messages.
Is there a way to ask if the property is computed and show a standard text instead.
This is the design definition.
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xc="http://www.ibm.com/xsp/custom">
<xp:inputText type="text" value="<%=this.field_name %>"></xp:inputText>
</xp:view>
Whenever the value of the property field_name is computed in the custom control it brings up that error.
Anybody any ideas?
When I insert the Field custom control with a static text value for field_name, the design definition will display the field_name properly.
<xc:Field field_type="text" field_name="myfield_1"></xc:Field>
If I insert the Field custom control with a computed text value for field_name, it doesn't:
<xc:Field field_type="text"><xc:this.field_name><![CDATA[# {javascript:"myfield_"+#Text(1)}]]></xc:this.field_name>
</xc:Field>
Make sure field_name is the exact name of the property passed in as CompositeData. For example, I was able to reference the string property 'create' to create the image of field this way:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:inputText value="<%=this.create%>">
</xp:inputText>
</xp:view>
So, I suspect it's a typo, a missing property, or not a string.

<xe:navigator> applying incorrect styling using OneUI 2.1

I am using a navigator control from the extension library. I want to use the default styling where only the selected item is highlighted and all the others are not highlighted and show the pointer cursor. For some reason it is applying the class "lotusSelected" to all the navigator nodes which are rendered as list items <li>.
I know that the "selected" property of tree nodes controls this. It does the same whether the property is set to true, false, or nothing. I am not trying to do anything fancy here, just use the default behavior. There is nothing in the custom css or theme to override this.
This happens on all browsers. Using Chrome tools I can see that removing the class causes the behavior I want. The navigation opens an XPage and changes a dynamic content control, this all works. This is used inside of the application layout control.
<?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">
<xe:navigator id="navigator1" expandable="false">
<xe:this.treeNodes>
<xe:pageTreeNode label="Add New ATM"
page="/xpSupervisor.xsp" queryString="content=newATM">
</xe:pageTreeNode>
<xe:pageTreeNode label="Update ATM Information"
page="/xpSupervisor.xsp" queryString="content=updateATM"
selected="false">
</xe:pageTreeNode>
<xe:pageTreeNode label="One Time Settlement Amount Change"
page="/xpSupervisor.xsp" queryString="content=changeSettlementAmt"
selected="false">
</xe:pageTreeNode>
</xe:this.treeNodes>
</xe:navigator></xp:view>
UPDATE: It seems to be some conflict between the pageTreeNode and the way I created the dynamic content control. It only messes up when on that one Xpage. Here is the code for that:
<?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">
<xe:dynamicContent id="dynamicContent1" useHash="true"
defaultFacet="default">
<xp:this.facets>
<xc:ccSupervisorHelp xp:key="default"></xc:ccSupervisorHelp>
<xc:ccNewATM xp:key="newATM"></xc:ccNewATM>
<xc:ccUpdateATM xp:key="updateATM"></xc:ccUpdateATM>
<xc:ccChangeSettlementAmt xp:key="changeSettlementAmt"></xc:ccChangeSettlementAmt>
</xp:this.facets>
</xe:dynamicContent>
</xp:view>
If I'am right, all nodes are selected because all nodes has the same page page="/xpSupervisor.xsp" as aim.
So if the page xpSupervisor.xsp is open, the navigator renders the nodes as select.
The property selected is only a boolean value, indicating whether the pageTreeNode is selected or not.
You should take a look at the property selection. This property is used in conjunction with navigationPath in the applicationLayout control. The property selection can take regular expressions to determine the selection state.
Despite two good answers which go me closer, I could not get the menu to work using the pageTreeNode. The fix was to switch to using a basicLeafNode and use a submittedValue and open the correct page in the onItemClick event of the navigator. I also added code in the 'selected' property to calculate which menu item was selected.
I could not get the context.getSubmittedValue() method to work in the selected property. I overcame this by setting it to a sessionScope var in the event. (viewScope didn't work for some reason)
<xe:basicLeafNode label="Update ATM Information" submitValue="updateATM">
<xe:this.selected><![CDATA[#{javascript:if(sessionScope.menuValue == "updateATM"){
return true;
} else {
return false;
}}]]></xe:this.selected></xe:basicLeafNode>
This is the code in the onItemClick that opens the correct link:
sessionScope.menuValue = context.getSubmittedValue();
if (sessionScope.menuValue == "newATM") {
context.redirectToPage("xpSupervisor.xsp?content=newATM");
} else...
The bottom of page 244 of the Extension Library book confirms this problem without offering a fix. Even though I have the book, hopefully this searchable answer will help others avoid the hassle I went through.

DataContext being executed multiple times

Has anyone noticed an issue with datacontexts in xpages. In certain scenario a single xpage with multiple custom controls would result in the datacontext being evaluated 12 times during a single page load?? Does this happen with other dataSources as well?
Here is a simple example, which gets executed 3 times!!
<?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:this.dataContexts>
<xp:dataContext var="doc1">
<xp:this.value><![CDATA[#{javascript:var doc:NotesDocument = database.createDocument();
doc.replaceItemValue("Form", "frmContact");
doc.replaceItemValue("fldFirstName", "test");
print("got here");
return doc;}]]></xp:this.value>
</xp:dataContext>
</xp:this.dataContexts>
<xp:inputText id="inputText1" value="#{doc1.fldFirstName}"></xp:inputText>
</xp:view>
Should I not be using dataContexts in my application?
And also watch out, if you are using partial refresh. Let's assume, you datacontext is in id B and you do a refresh on id A. The datacontext in id B will also be refreshed. Also happens to all other data sources.
I have described this behaviour here http://www-10.lotus.com/ldd/xpagesforum.nsf/topicThread.xsp?action=openDocument&documentId=56E9B8537DA50A90852579A6002EAC64#FA00DE3675A456C0852579AB005A1FF4
And there are also some hints about a PMR and a possible workaround for this.
Just like other controls on the page, the datacontext could be evaluated multiple times. See here for more information about the benefits of dataContexts. But in my opinion, from your code example, it could be faster to use a xp:data source but I'm not sure.
As with all other value bindings, if you change the # to a $, the value attribute of the dataContext may be requested multiple times, but the calculation to determine that value will only be executed once.

Resources