How do I perform an action when a button in a WinJS ContentDialog is clicked? - winjs

I am new to WinJS, and I want to make a ContentDialog that will contain a textbox, for entering an API key and Submit and Cancel buttons. When the ok button is clicked, a method should be triggered that will do a bit of validation and then persist the data. I have been trying to find out how I can add an event listener to one of the ContentDialog buttons but cannot find out how. I have been googling, and found:
http://try.buildwinjs.com/#contentdialog
https://msdn.microsoft.com/en-us/library/windows/apps/dn904229.aspx
https://mindfiremobile.wordpress.com/2013/08/27/displaying-dialogs-in-winjs/
None of these hint on how to accomplish this. Can this be done? If so how?

in your JS code add:
var button1 = document.getElementById("button1");
button1.addEventListener("click", button1Click, false)
'button1' is the id of the HTML element.
'button1Click' is your js function to perform the action.

Related

How to get the hand/controller that pressed a button

I would like to know, just by subscribing to the Interactable OnClick event, if I pressed the button with my left or right hand. Would that even be possible without passing this information along with the OnClick event?
The button has quite the logic to go through until it decides to accept a click request, so replicating all of that via global listener is not feasible.
Is it possible to get that information OnClick from somewhere else? Is it possible to query the potential click sources for who that was?
Without altering the Interactable class the only way I found was to query the FocusProvider for the active pointer, which must have been the one pressing the button (in my case):
https://microsoft.github.io/MixedRealityToolkit-Unity/Documentation/Input/Pointers.html
https://microsoft.github.io/MixedRealityToolkit-Unity/Documentation/Input/Controllers.html
Setup your controllers, take note of the axis name, in code you can do something like this in any GameObject's update loop:
if (Input.GetAxis("Axis1D.PrimaryHandButton") > 0.5f) {
// this axis (button) is pressed do something
}

xpages extension library dialog update data table

I have a xpages page that has a data table in a panel that calls an extension library dialog whose function is to create documents that are displayed in that data table. I would like to know if there is any way to by pressing the button to close the dialog refresh the data table with the new documents created.
I've used what's mentioned here to achieve that in the past:
XPages:dialog box refreshing a panel on close
Use a parameter in the .hide method to specify a control to refresh when closing the dialog. https://www-10.lotus.com/ldd/ddwiki.nsf/xpDocViewer.xsp?lookupName=Domino+Designer+XPages+Extension+Library#action=openDocument&res_title=Modal_dialogs_ddxl853&content=pdcontent
I was able to close the dialog box and update the data table as follows:
In the onClick event on the client side, and I put the code:
Dijit.byId ("# {id: dialogboxname}"). Hide ("panelWithDataTable")
And in the onComplete event of the button I use the code below:
Var idPanel = '# {id: panelWithDataTable}';
XSP.partialRefreshGet (idPanel)

How to make popUp not submit form on startup?

I am using JDeveloper 11.1.2.3.0,
I have a createInsert button that has ShowPopUp Behavior operation included. In the popUp I have inserted a form whose attributes will be clean from the createInsert operation. When I click the button the popUp shows up all right but showing an error about the mandatory fields of the form. The fields of the form of course are empty because I just opened it. So I think that the popUp is autoSubmiting the form at the starting point.
Does anyone have an idea how to stop it from doing this?
I have changed the createInsert button PartialSubmit property to false but nothing changed.
Ok found the solution. The popUp was not submitting anything actually but during the CreateInsert operation the iterator opens a new row in every related component within that page (form, table etc). So when my popUp opened up with the new form fields, a new row was being created in the back-stage in my read-only table. I changed the iterator in a new one from another Application Module for each case and everything is fine now.

How to identify a button click in coded UI Customised code

In UIMAP.CS file in both the Recorded method and assertion method, I am not able to identify the button click.
Is there any way I can get hold of the button click event?
I am able to get hold the button in to a UITESTCONTROL variable but the options I was able to see are "exists", "enabled","name" etc...
I tried checking it with assertions too when I dragged the cross hair on to the clicked button , assertions are generated only for checking the existence,correctness of text and name but not the events occured on it..
Please help in this regard..
Please make sure that the Control/Object on which you want to use the Click operation is a button and not any Web Element or control which does not support the Click operation.
Once verified, you can do the following:
Record a New Session and while recording click on that button, stop your recording.
Open the UIMap.cs and navigate to that button control. The intellitrace would show you all the available options for that control.
Thanks
Nikhil

XPages remove documents on server and trigger partial refresh

I am struggling with the following.
On my XPage I have a viewpanel component, but it is not bound to a notesview datasource, but to a hashmap stored in viewScope. Reasons for this is beyond scope of my question.
Since the lines in my view are not actually linked to the documents I cannot use the standard checkboxes and the related getSelectedDocIds. I do however want a way to remove the selected documents. I have a column with checkboxes containing the unid of the corresponding row.
So long story short. I have an array of unids and want to perform an action that does the following:
Display a dijit.Dialog asking for confirmation
If OK clicked call a function that does the following:
Remove the documents based on the unids
Refresh the viewpanel
I am thinking of the following 2 solutions, but in doubt what would be best (maybe a third, even simpler solution?)
Have the OK button of the dojo dialog call a function that does an XmlHttpRequest to an XAgent or plain old LS agent
Have the OK button trigger an eventhandler that runs on the server as described by JeremyHodge here. But how would I pass the unids as parameter and refresh the view afterwards?
Thanks!
Cant you just make use of the extension library dialog with the dialog button control. In this button control you can then
A third option would be to add a column to your datatable/view which contains checkboxes. On the onchange event of these boxes you add an eventhander which adds the value to a viewScope variable.
A button on the bottom (or top.) of the page you add the code you need to remove the selected items from the hashmap, delete the documents associate with the selected id's. this button can be a ordinary button with a partial refresh on the viewpanel. When you run into the bug that you cant use buttons in a dialog please use the extension library dialog control because this fixes that issue for you.
If the current user does not have the correct access level to delete documents you could use the sessionAsSigner global (assuming the signer of the design element has the correct access levels).
This way you dont need to go call an xAgent by xmlthttprequest and can stay with the default xpage methodology.
I hope this helps in some way
I would second #jjbsomhorst in the use of the extension library for the dialog box - if you use one at all. Usually users don't read dialog boxes. So the approach would be add the column with the checkboxes, but don't bother with an event handler, but bind them ALL with their value to ONE scopeVariable. On submission that variable will then hold an array with the selected UNID.
Then render a page that lists these documents and have a confirm button. While the new page affords a server round-trip the likelihood, that users actually pay attention is way higher. What you can do:
Have the normal page that renders the dialog with editable checkboxes and when the user clicks "Delete" you set something like viewScope.confirmDeleteMode=true; and use that as condition for the checkboxes and make them read-only AND set the class of the selected rows to "morituri" which in your CSS would have something like .morituri { color: white; background-color : red; font-weight: bold } and a new button "Confirm Delete" (and hide the Delete button).
This way you only have one page to deal with.
I went for option 2, which has the possibility to provide the partial refresh id. I passed the unids as a submitvalue like:
function doRemove(unids){
XSP.executeOnServer(ISP.UI.removeEventID, ISP.UI.removeRefreshID, {
params: {
'$$xspsubmitvalue': unids
},
onComplete : function() {
//alert('test')
}
});
}
The ISP.UI.removeEventID performs the following code:
var unids = context.getSubmittedValue();
removeDocuments(unids); //SSJS function performing the actual delete
viewScope.reload = 'reload' //triggers the hashmap to be rebuild based on new documentcollection

Resources