xpages: compute Confirm Action confirmation text does not work in XPiNC - xpages

I'm using Notes/Domino 8.5.3. I've added a button control to an xpage. The button uses a Confirm Action to display a client-side prompt to the user before continuing with the next action defined for the button. When I use static text for the Confirmation Text for the Confirm Action, the confirmation prompt is displayed. However, when I change the Confirmation Text to be computed, and retrieve the text from a profile document, the confirmation prompt it not displayed at all in XPiNC. The confirmation prompt with the computed confirmation text is displayed just fine in a browser. Is there a work-around for this issue with XPiNC?
Following is the code I'm using in the Confirm Action to get the text for the prompt:
var server = database.getServer();
var dbProfile:NotesDocument = database.getProfileDocument("DBProfile", "");
var msg = dbProfile.getItemValueString("ContactsInitUpdatePrompt");
return msg;

To further my comments, this is a work around I use the below code for an app that uses the bootstrap extension library on the web but uses basic functionality with xpinc.
If the values for xPinc are different you could make the confirm action different in the browser and in the client.
if (#ClientType()== "Notes")
{
<action>;
}
else{
<action>;
}
I think that profile documents are a bad idea in xPages though. Having to restart HTTP to get a new value ruins the point I think. Almost better to hard code values at that point. I think you can set application scope to handle the work of profile documents. But then application scope in xpinc is just on the current machine as the server is the client.

Related

Alert in view record for Netsuite

I have been trying to get a alert in Netsuite for view mode but can't get it for customer record.
Though when I tried to get the alert for the edit record then I got it but I want it for view.
I tried client script, user event script and also workflow. But all support only for edit. Can I get the alert by any means for the view record option.
Thanks
Gladiator
One workaround that I've done is to add a custom field of type 'Inline HTML' to the customer form. Then during the beforeLoad event you can check if type == 'view' and update the custom field's value with the HTML that is needed to display the alert.
Basically form.setScript used to work with SS1 but there was no (not hacked) API access to Netsuite's alerts
SS2.0 gives nice access to the alert system but it doesn't load in view mode unless you take a supported action (clicking a button)
See this answer for a sample with SS2 that loads your script and shows an integrated alert.
SS2.0 Display Message on Record
Thanks Mike, Michoel and Bknights.
Here is the solution to the problem.
Create an inline html field on the customer form.
Since the field does not store value nlapiSetFieldValue for before load function works absolutely fine.
Below is the snippet of the working code.
function before_load(type)
{
if (type == 'view')
{
var pass_value = "<html><body><script type='text/javascript'>window.alert('Hello World!!!')</script></body></html>";
nlapiSetFieldValue("custentity25", pass_value); //custentity25 is the id of Inline HTML field we created
}
}
Note : The "" used should be different then the one used in the HTML code which is ''. If same are used then there will be an error.
You need to use a User Event Script, and in the before load event, set a Client Script via form.setScript(). In your "injected" Client Script, you can display the alert.

Execute action/button when user hits enter

Application uses frameset, where top frame contains banner (form) with searchbox (text field rendered OS style) and button to perform search.
Users want to execute search when they hit enter in that field.
I have already implemented javascript (in Notes client at form level) to catch 13 key and issue button.click(). This was very troublesome (if user keeps application open for long time, Notes client usualy hangs).
I am looking for solution / ideas to make this work - if user hits enter in text field, some action will be invoked (#Formula, LotusScript, JavaScript).
Using Javascript in the Notes client you can set a timer to poll the search field every, say, half second, and trigger your search function when you see a Newline / CR character in the search field. See this post for more details and actual code sample:
http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/c7ce0bad6b6ec83385257180007d6761?OpenDocument

XPages: execute context.redirectToPage after client side function?

Why does context.redirectToPage behave differently when executed in a view root-event instead of an event handler?
This question came up when I tried to set the language of an xpages application to the language saved in the user profile, once the user is logged in. I use a properties-file with translated strings in a resource bundle, and retrieve the strings like this:
<xp:text value="${langString['WELCOME_TEXT']}" />
When the language is changed and so a different properties-file is loaded, the page needs to be refreshed in order to update those strings. This worked fine when I added a full-refresh event handler to the login button, that executed a server side context.redirectToPage(). No luck with client side refreshes like location.reload or window.location.href=window.location.href (the login-function itself is a client side function though).
But of course the user expects that he is also logged in when he presses the enter key instead of the button after he has entered his credentials. So I added an onkeypress-event to the username and password input fields, and checked for the enter key (if (thisEvent.keyCode==13) dosomething...) before executing the login function.
But now the event handler is called every time a key is pressed and of course I do not want the context.redirectToPage to be executed all the time.
Thus I removed the server side event handlers and changed the login function so that it terminated with a partial refresh of the div containing the whole page:
var p = {"execLogin":"true"}; XSP.partialRefreshPost( '#{id:wholePage}', {params: p} );
The parameter sent via the partial refresh now triggers an event in which our context.redirectToPage is executed:
<xp:this.beforeRenderResponse><![CDATA[#{javascript:if (param.containsKey('execLogin') && param.get('execLogin').toString().equals('true')) {
print("test");
context.redirectToPage(context.getUrl().toSiteRelativeString(context),true);
}}]]></xp:this.beforeRenderResponse>
The page is refreshed and "test" is printed out, but I still see the old language strings. I have to refresh the page manually again to make the new user language take effect.
Any idea how to execute a genuine full refresh this way, or maybe another way to update the strings retrieved from the property bundle?
Thanks in advance. Regards,
Sarah
EDIT
I now have:
<xp:inputText id="cc_login_panel_login_username" styleClass="span2">
<xp:eventHandler event="onkeypress" submit="true" refreshMode="complete">
<xp:this.script><![CDATA[if (thisEvent.keyCode!=13) {
return false;
} else {
doLogin();
return true;
}]]></xp:this.script>
<xp:this.action><![CDATA[#{javascript:context.redirectToPage(context.getUrl().toSiteRelativeString(context));}]]></xp:this.action>
</xp:eventHandler>
Because context.reloadPage() didn't even log me in somehow (strange) I got back to using redirectToPage. The server side event is fired once and at the right time *thumbs up*, but the language properties-bevaviour is still the same.
$ is only set on page load, whereas # is set each time during the partial refresh.
I don't think a partial refresh will work at all though. This will refresh the computed field. However, it will need a full refresh to refresh the part of the XPage that includes the properties file. In other words, you would be refreshing the computed field, but using the same properties file.
I wonder if context.redirectToPage or context.reloadPage is somehow going to the same page but with the cached properties files.
If you're always wanting to come back to the same page, a full refresh instead of partial refresh may be the best option.
I think this has something to do with using the $ parameter. this tells the runtime to retrieve the language file the first time the current page is created in the back-end. When a user does a refresh it is actualy retrieving a saved version of the page you are viewing.
I see you're calling "context.redirectToPage(context.getURL().toSiteRelativeString(context)))" within an xp:this.action tag for the xp:eventHandler.
Try using xp:this.onComplete in place of xp:this.action.
According to the Designer tooltip for the action, the expected return is a string to be passed to the navigation handler. So instead giving the onComplete will execute the redirect command when it's done with the eventHandler group of events.
Thanks for all the helpful answers, in fact all of them did work, the problem turned out to be my misunderstanding of when the properties-file is loaded. It is loaded in an early phase, long before my new language is set to the sessionScope (that sessionScope variable is then used as a part of the name of the properties-file to be loaded, via the VariableResolver).
Now I use a double full refresh to load the new file. When the login function terminates successfully, it executes:
window.location.href = window.location.href + "?doRefresh=true";
And to the view root element I added the following event:
<xp:this.beforeRenderResponse><![CDATA[#{javascript:
if (context.getUrlParameter("doRefresh")!=null&&context.getUrlParameter("doRefresh").equals("true")) {
var url = context.getUrl().toSiteRelativeString(context);
url = url.replace("?doRefresh=true","");
context.redirectToPage(url);}
}]]></xp:this.beforeRenderResponse>
This is not a very sophisticated solution, but at least it works :-)

SharePoint Dataform webpart redirection issue

I have two web parts in my sharepoint aspx web page. One is Content editor web part and the other is data form web part.
In data form web part, I have a data view and I need to pass a parameter "id" to this dataview which will show the project details in the data view. I tried to use a value from a control as a parameter and never had a success. I did googled a lot last few days and haven't found any solution. It would be great, if someone show me a way to use the text from a control (may be a text box or select control). if someone have a working sample, please share. Alternatively I have used a query string as a parameter (eventhough I prefer to use text from a control). We need to pass a query string called id. For example, I am navigating to http://localhost/pages/1.aspx?id=7. This will show the project details of project id 7 in data form web part. this works fine.
I need to provide an option to user to enter the project id instead of modifying the query string in url. To achieve that I used content editor web part and I have a text box text1 and a submit button (html controls). The user will enter project id in the text box provided and will click the submit button to view the project details in dataview. The submit button javascript code has the following code:
url = 'http://localhost/pages/1.aspx?id=7';
alert (url); //alerts as http://localhost/pages/1.aspx?id=7
window.location = url;
For testing purpose, I just hardcoded the url. However, clicking the submit button is not redirecting to http://localhost/pages/1.aspx?id=7 or something happens during redirect. The page just reloads once. i.e., if I am in http://localhost/pages/1.aspx?id=12 and clicking the submit button reloads the page http://localhost/pages/1.aspx?id=12 instead of navigating to http://localhost/pages/1.aspx?id=7.
Without data form web part, the redirect works fine. Kindly help.
Thank you

How to control application from WebBrowser Control?

I've googled it, but came out empty. And the worst thing is that I know it is possible.
Anyway, I'm developing an application that uses the WebBrowser control to display information regarding an object (like Outlook does with the Rules and Alerts dialog box).
My question is how do I do for the click on a, say, hyperlink in the WebBrowser execute some function within the Windows Form?
For instance, say I have a link like this and when I click it I want the application to display an specific form, like the Outlook does when you click on hyperlinks like People and Distribution List
This looks useful: How to: Implement Two-Way Communication Between DHTML Code and Client Application Code
ChrisW's answer will work, but there's another way if you're just relying on hyperlinks.
In Comicster, I have links in my WebBrowser control like this:
New Collection
And then in the WebBrowser's Navigating event, I have some code to check if the user has tried to navigate to an "action:" link, and intercept it:
private void webBrowser1_Navigating(object sender,
WebBrowserNavigatingEventArgs e)
{
if (e.Url.Scheme == "action")
{
e.Cancel = true;
string actionName = e.Url.LocalPath;
// do stuff when actionName == "FileNew" etc
}
}
With a little bit of code you can even parse the URL parameters and "pass them through" to your host application's action, so I can do things like:
Edit this issue
... which will open a properties dialog for the issue with ID 1.

Resources