executeonServer from a customcontrol - how caputer Id from current CC - xpages

Ho to all,
I have a little problem..my code work very well..if I have my event handler into a XPages
`<xp:eventHandler event="autoSaveEvent" id="autoSaveDoc"
submit="false">
<xp:this.action>
<xp:saveDocument>
</xp:saveDocument>
</xp:this.action>
</xp:eventHandler>`
but If I insert this into a Custom Control...the executeonserver don't work...
I have read from here stack overflow post but for work I need to capture the id of my Custom Control..someone have any suggest?

If you want to get the customcontrol you could probably do something like this.
where abc is the name of a top level component in the custom control.
var ccId = '#{javascript:getComponent('abc').getParent().getId()}';

Tnx you #Fredrik Norling this is very good suggest!
this code below code work in every tree of child of where you insert the CC:
var eventId="#{javascript:getClientId('autoSaveDoc')}"
var n=eventId.split("view:_id1:");
var ccId=n[1];

Related

How to get marked rows in the XPages Extension Library <xe:dataView> design element?

I have a XPage with design element. How can I get list of checked rows to post it to an agent?
<xe:dataView id="dataView1" columnTitles="true"
expandedDetail="true" var="dview1"
openDocAsReadonly="false" rows="15" showCheckbox="true"
showHeaderCheckbox="true">
Thank you!
For the client-side, you can use Dojo. The following CSJS script will return NoteIds for all selected rows:
dojo.query(".lotusFirstCell > input:checked").attr('value')
For the server side, you can grab the IDs of selected documents by:
var idList = getComponent("dataView1").getSelectedIds();
This will return a string array of NoteIDs. Then pass it to an in-memory document and call the agent.
var doc = database.createDocument();
doc.replaceItemValue("IDList", IDList);
var agent:NotesAgent=database.getAgent("SomeAgent");
agent.runWithDocumentContext(doc);
Perfect!
This is exactly what I need:
var IDs = dojo.query(".xspFirstCell > input:checked").attr('value');

Specialized type-ahead

I am trying to provide type-ahead functionality for a job number field. The pattern of the field is 8 followed by as many zeros as necessary to make the string they type a total of 10 digits. In other words, 8000001234 or 8001234567. In these examples, the users only want to type 1234 or 1234567 and have the type-ahead return the corresponding documents. Is this possible?
This can be done by using the parameter valueMarkup in xp:typeAhead.
In the suggestion response you add the value you wish to add to the field in the display:none section, the span of class informal is the part display in the suggestion list. You can modify/design the informal section with HTML code (f.e. include multiline informations, add images, etc.)
Here is a simple example:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:inputText id="inputText1" value="#{requestScope.TypeAhead}">
<xp:typeAhead mode="partial" minChars="1"
var="searchValue" valueMarkup="true">
<xp:this.valueList>
<![CDATA[#{javascript:
var directoryTypeahead = function (searchValue:string) {
/*** generate your matches ***/
var matches = {};
for( var i=10;i<20;i++){
matches[i] = { display: "80000" + i };
}
/*** return typeahead data ***/
var returnList = "<ul>";
for (var matchEntry in matches) {
var match = matches[matchEntry];
var matchDetails:string = [
"<li><div style=\"display:none;\">",
matchEntry,
"</div><span class=\"informal\"><strong>",
match.display,
"</span></li>"
].join("");
returnList += matchDetails;
}
returnList += "</ul>";
return returnList;
}
directoryTypeahead(searchValue)
}]]>
</xp:this.valueList>
</xp:typeAhead>
</xp:inputText>
You have to change the part between generate your matches to fit your requirements.
Roy - another options would be to roll your own typeAhead and not use the out of the box version
http://xomino.com/2012/05/01/jquery-in-xpages-8-tokeninput-autocomplete/
Using the Token Autocomplete you can control the search input and the display output - in this way you can display the whole 80000123 string and the 123 would be highlighted as the text that the user has input.
Possibly a partial answer - but I stumbled across a blog post by Rasmus Bauck a while back that explained a technique for handling the type-ahead calls with code of your own.
I didn't get around to trying it, but I saw your question and it jogged my memory.
http://devxpages.blogspot.com.au/2010/04/extending-xpages-type-ahead.html
Hope it helps,
Brendan

how to i mplement autocomplete using yui

As am totally new to YUI i dont have any clue about.I have just gone through this link to implement autocomplete using YUI http://developer.yahoo.com/yui/autocomplete/.
According to my requirement i need to assign a string array dynamically to datasource object instead of
var dsLocalArray = new YAHOO.util.LocalDataSource(["apples", "broccoli", "cherries"]);
something like
var dsLocalArray=new YAHOO.util.LocalDataSource(documentList[]);
where my documentList is String Array.How do i that?Thanks in advance for the help.
I would suggest you to use YUI3 than YUI2, the example you are showing which uses the YAHOO namespace which is YUI2.
YUI3 is simpler and better, you can get the docs here:
http://yuilibrary.com/yui/docs/autocomplete/
Example of implementing with YUI3 including highlighting feature:
YUI().use('autocomplete', 'autocomplete-filters', 'autocomplete-highlighters', function (Y) {
Y.one('#ac-input').plug(Y.Plugin.AutoComplete, {
resultFilters : 'phraseMatch',
resultHighlighter: 'phraseMatch',
source : ['Alabama','Alaska','Arizona','Arkansas','California']
});
});
Try to lok into the examples at the right bottom side panel in the above docs link.

save() method on datasource does not fire querySave/postSave events

My save button uses SSJS with some logic. I want to save datasource, so I use
document1.save();
Script works, but querySave/postSave code is not executed.
Only workaround is to use simple action and divide button event to blocks for "execute script", "Save document (simple action)" and "execute script" (just to return "navigation" string).
Is it possible to save datasource in SSJS and fire qS/pS events?
please try this SSJS code:
var dsName = "document1.DATASOURCE";
var app = facesContext.getApplication();
var ds = app.getVariableResolver().resolveVariable(facesContext, dsName);
ds.save( facesContext, true );
The variable dsName contains the name of your datasource followed by ".DATASOURCE". To use it f.e. with current document, you have to change to "currentDocument.DATASOURCE".
Hope this helps
Sven
Sven what is the difference between your code and currentDocument.save() is something else happening than querysave and postsave?

how to get window width and height with YUI?

How do I get those values? I see the example on the YUI page to do this but using a click event, and then calling the get('winWidth') method on the event target. But how can I get these values without the use of any event? Thanks
Simply
YAHOO.util.Dom.getViewportWidth();
YAHOO.util.Dom.getViewportHeight();
keep in mind you can reduce YUI namespace as shown bellow
(function() {
var Yutil = YAHOO.util,
Ydom = Ytil.Dom;
Ydom.getViewportWidth();
Ydom.getViewportHeight();
})();

Resources