XPage: OnClick Event Listbox don't work properly - xpages

I'm using a listbox on an xpage which is using computed values
<xp:listBox id="listboxAutorInstitution"
styleClass="listBoxPicklist">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:getValuesPicklist("authorRT")}]]></xp:this.value>
</xp:selectItems>
<xp:eventHandler event="ondblclick"
submit="true" refreshMode="partial" refreshId="ccAuthor">
<xp:this.action><![CDATA[#{javascript:view.postScript("console.log('" + getComponent("listboxAuthor").value +"')")}]]></xp:this.action>
</xp:eventHandler>
</xp:listBox>
The values come from a rich-text field on a profiledocument.
function getValuesPicklist(fieldName) {
var db: NotesDatabase = session.getCurrentDatabase();
var doc: NotesDocument = db.getProfileDocument("(Config)", "");
var list = #Trim(doc.getFirstItem(fieldName).getValueString().split("|"));
return list.sort(function(a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
});
}
If I load the xpage on browser and clicking an element from listbox the console.log('') script is only run for some elements.
The trace log shows me the following error message:
Validation Error: Value is not valid
What could be the cause for this behaviour?
SOLVED:
I solved the problem by using
doc.getFirstItem(fieldName).getUnformattedText().split("|");
instead of
doc.getFirstItem(fieldName).getValueString().split("|");

Based on discussion:
1) You can disable validation: http://www-10.lotus.com/ldd/ddwiki.nsf/dx/XPagesNoDataValidation.htm
I am not sure it will help with listbox, though.
2) Seems, there is something wrong with that profile - my guess is "enter" or some invisible character somewhere at the beginning or end of some keywords (very common with copy/paste from other sources). Try to cut everything, paste to notepad, and copy/paste back.
By the way, it is pretty odd to use Rich Text field to keep keywords...

see my Update in the question post!

Related

Selecting and Closing djTabPane in djTabContainer

I wonder, if someone has THE CLUE for me on one of my devel problem (sure you do ;-) ).
I try to use a "Dojo Tab Container" with dynamic Dojo Tab Panes.
<xp:div id="tabs">
<xe:djTabContainer id="djTabContainer1" tabPosition="top"
style="height:250px;width:500px" defaultTabContent="defTab">
<xp:this.facets>
<xe:djTabPane xp:key="defTab" id="myTab" partialEvents="true" closable="true">
<xp:panel>
<xp:label value="#{javascript:getComponent('myTab').getTitle()}"></xp:label>
</xp:panel>
</xe:djTabPane>
</xp:this.facets>
</xe:djTabContainer>
</xp:div>
Then there's a SSJS (button) event to add tabs (actually the action is more complex to calculate title etc., but this should explain):
var cont:com.ibm.xsp.extlib.component.dojo.layout.UIDojoTabContainer = getComponent('djTabContainer1');
cont.createTab({id:'tab1', tabUniqueKey:'tab1', tabTitle:'tab1'});
cont.createTab({id:'tab2', tabUniqueKey:'tab2', tabTitle:'tab2'});
cont.createTab({id:'tab3', tabUniqueKey:'tab3', tabTitle:'tab3'});
Now I want to programmatically switch (open) to another tab, or close a tab. It's quite difficult to find useful examples here.
I found out, that I can programmatically switch to another tab via cont.setSelectedTab('2') instead of cont.setSelectedTab('tab2') - as I would expect. For some reason the tabUniqueKey parameter is fully ignored, while the tabTitle parameter isn't. Even worse: it looks like all createTab()-parameters are ignored, except of tabTitle.
Is there an elegant way to get the tab pane component? getComponent('tab2') doesn't work. Neither "id:'tab2'" nor "tabUniqueKey:'tab2'" are taken in account. I can get a tab using getComponent('myTab'), but that's fully useless, if all tabs have the same id.
So, neither does
var cont:com.ibm.xsp.extlib.component.dojo.layout.UIDojoTabContainer = getComponent('djTabContainer1');
var tabSel:com.ibm.xsp.extlib.component.dojo.layout.UIDojoTabPane = comp.selectTab('tab2');
nor
var tabSel:com.ibm.xsp.extlib.component.dojo.layout.UIDojoTabPane = comp.setSelectedTab('tab2');
At least what I'm looking for is something similar to:
cont.closeTab('tab3'); // to close tab3
createTab() returns a UIDojoTabPane pane object and you can use it to select the created tab afterwards:
var cont:com.ibm.xsp.extlib.component.dojo.layout.UIDojoTabContainer = getComponent('djTabContainer1');
var paneTab1:com.ibm.xsp.extlib.component.dojo.layout.UIDojoTabPane = cont.createTab({id:'tab1', tabUniqueKey:'tab1', tabTitle:'tab1'});
...
cont.setSelectedTab(paneTab1.getTabUniqueKey());
You can use this pane object to close the tab too:
paneTab1.closeTab()

XPages ftsearch results for combobox fields

I created on my previous applications a simple FTsearch module, displaying the results inside a viewPanel1.
But, now in other app it gives me a headache. The search code from the view:
var tmpArray = new Array("");
var cTerms = 0;
if (sessionScope.searchFurnizor) {
tmpArray[cTerms++] = "(Field txt_particontractcv_1 = \"*" + sessionScope.searchFurnizor + "*\")";
}
if (sessionScope.searchStare) {
tmpArray[cTerms++] = "(Field txt_stadiucontrcv = \"*" + sessionScope.searchStare + "*\")";
}
qstring = tmpArray.join(" AND ").trim();
sessionScope.queryString = qstring;
return qstring
The txt_particontractcv_1 is a simple inputText and txt_stadiucontrcv is a checkbox:
<xp:checkBoxGroup id="checkBoxGroup1" value="#{Contr.txt_stadiucontrcv}" defaultValue="In derulare">
<xp:selectItem itemLabel="In derulare" itemValue="In derulare"
id="selectItem1">
</xp:selectItem>
<xp:selectItem itemLabel="Finalizat" itemValue="Finalizat"
id="selectItem2">
</xp:selectItem>
</xp:checkBoxGroup>
The button which submits the search is doing a partial refresh to viewPanel1. Still, it returns 0 results even there are documents respecting the filter criteria inside the search.
LATER EDIT: After deleting one by one fields from the FTsearch module, I think I found the issue: the problem is at the fields which are comboboxes ( my case ) in the document content but also inside the FTsearch modulo. The code for the combobox from the FTsearch:
<xp:checkBoxGroup id="checkBoxGroup1" value="#{sessionScope.searchStare}">
<xp:selectItem itemLabel="In derulare" itemValue="In derulare" id="selectItem1">
</xp:selectItem>
<xp:selectItem itemLabel="Finalizat" itemValue="Finalizat" id="selectItem2">
</xp:selectItem>
</xp:checkBoxGroup>
Also, I noticed that the inputField(s) must be inputText, I try with some comoboboxes as input fields, but not working.
Are you refreshing the view in the partialrefresh or a panel outside of the view?
because if you are refreshing the view you probably never update the search query. If so add an xp:panel or xp:div out side of the view and do the partial refresh on that.
Whenever a full text search is not working how you expect it to, my recommendation is always to print out the search string. Then try performing the search in a view in the Notes Client.
If it doesn't work in the view in the client, trying to resolve it in your XPage will not get it working. The Notes Client will tell you why, usually "Query is not understandable" and you can troubleshoot why using the buttons in the search bar in Notes, which tells you which fields are available and what data type the UNK table thinks they are.
If it does work, there's a problem somewhere in your XPage.
As ever, break it down to try to identify where the problem is - in this case the full text search functionality or the implementation of it in XPages.

onchange event in XPages

I have two edit boxes in an XPage and one label.
Leave Start Date : EDIT BOX
Leave End Date : EDIT Box
Holidays Taken : label
I want to calulate the diffence in dates and get it computed in the label using the following code in onChange event of second(Leave End Date) edit box but on chaging the value of the edit box it clears the two field and nothing gets computed:
var leaveStartDate = document1.getValue("fld_Leave_Start_Date1");
var leaveEndDate = document1.getValue("fld_Leave_End_Date1");
var difference = null;
try{
var nDateStart = session.createDateTime( leaveStartDate );
var nDateEnd = session.createDateTime( leaveEndDate );
difference = nDateEnd.timeDifference(nDateStart);
difference = (Math.floor(difference/86400)) + 1;
}catch(e)
{
return e
}
document1.setValue("fld_NoOfDays",difference);
I tried getComponent("fld_Leave_Start_Date1").getSubmittedValue(), but didn't work either.
Can someone please help.
Thanks a lot in advance!
If the edit boxes are getting cleared, it sounds like you've set the event to do a full refresh instead of a partial refresh.
The other possible cause of clearing fields is if you're using Partial Execution Mode (execMode="Partial" in the source pane for the eventHandler) but have specified a execId that does not include the two edit boxes. (Partial Execution by default runs on the current component, so you should not lose the values of that Edit Box.) But I don't think that's the case.

In a xe:dataView how to code the summary facet to show/hide the detail facet?

By default the summary column adds a link to open the underlying document as specified in the dataView's pageName property. I have a use-case where I want to keep the application in the dataView, and not open any "documentXPage".
I know this could be done in a repeat, but there are other parts/functionality of the dataView that work nicely for the application, so ideally I'm just looking to override the default behavior of the summaryColumn.
To override the link behavior I added the summary column as a facet, instead of a property, as in:
<xp:this.facets>
<xp:panel xp:key="summary" id="summaryPanel">
<xp:text escape="false" id="computedField3">
<xp:this.value><![CDATA[#{javascript:
var custName = viewEntry.getColumnValue("Customer");
return "<h4>"+custName+"</h4>"}]]>
</xp:this.value>
</xp:text>
</xp:panel>
<xp:panel xp:key="detail" id="detailsPanel" readonly="true">
<xp:text escape="true" id="computedField1">
<xp:this.value><![CDATA[{javascript:
viewEntry.getDocument().getItemValueString("Address") + ", " +
viewEntry.getDocument().getItemValueString("City") + ", " +
viewEntry.getDocument().getItemValueString("State")}]]>
</xp:this.value>
</xp:text>
</xp:panel>
<\xp:this.facets>
How do I code my summary facet to show/hide the details facet when clicked?
It depends on the setting detailsOnClient.
If that is set to true, you should be able to use CSJS to set display to "block" or "none" and you should be able to work out the ID of the element you need to change, using getComponent("dataView1").getRowIndex() (assuming your dataView has the ID dataView1)
This is also the key to doing the same if detailsOnClient is false. The following code will work.
var idex=getComponent("dataView1").getRowIndex();
getComponent("dataView1").toggleDetailVisible(#Text(idex+1));
You're basically getting a handle on the current rowIndex (which starts at 0), adding 1 to get the row to toggle and converting it to text. The DataView control has a method toggleDetailVisible(String) which is used to do the toggle.
As stated by #Mikael in Domino 9 the toggleDetailVisible function does not seem to work. Based on a suggestion from Brad Balassaitis I got it working by getting a handle to the twistie object and clicking it.
var myid = "#{id:link3}";
var parts = myid.split(":");
var outparts = [];
for(var idx=0; idx<parts.length-1; idx++){
outparts[idx] = parts[idx];
}
outparts[outparts.length-1] += "_shimg";
var bid = outparts.join(":");
var btn = document.getElementById(bid);
btn.click();

Referencing text input fields in CKEditor dialogs

I've been playing around with this for a couple of weeks now with no success...
In a CKEditor dialog, text input fields are renamed with a unique number - e.g. id: 'txtUrl' will become something like id='27_textinput'.
How do I reference this?
// I feel it should be something like:
var myfield = CKEDITOR.instances.myElement.document.$.body.getId('txtUrl');
// or maybe:
var myfield = CKEDITOR.dialog.getContentElement('info','txtUrl');
// and then:
myfield.value = 'myvalue';
But these don't work. Please help! Thanks in advance, R
This was the final solution:
var dialog = CKEDITOR.dialog.getCurrent();
dialog.setValueOf('info','txtUrl',"http://google.com");
return false;
within an onchange part of an element I now use
dialog = this.getDialog();
alert(dialog.getContentElement('info', 'grootte').getInputElement().$.id);
and it gives 'cke_117_select' as a result. (It's a selectbox)
alert(dialog.getContentElement('info', 'txtUrl').getInputElement().$.id);
gives 'cke_107_textInput'.
I think this is what you (or other visitors to this page) are looking for.
You have a page containing the CKEditor 3 and a dialog pop up. You open from this dialog, another pop up window, that is a JSP page. In order to set a value to a field in the dialog of CKEditor's parent window, you do the following:
window.opener.CKEDITOR.dialog.getCurrent().getContentElement('dialogTabId', 'dialogTabFieldId').setValue('yourValue');
This applies to CKEditor 3.
Look at the api dialog sample:
// Get a reference to the "Link Info" tab.
var infoTab = dialogDefinition.getContents( 'info' );
// Set the default value for the URL field.
var urlField = infoTab.get( 'url' );
urlField['default'] = 'www.example.com';
get
var ckValue = CKEDITOR.instances['txtUrl'].getData();
and set
CKEDITOR.instances['txtUrl'].setData(ckValue);

Resources