Friendly URLs in XPages - xpages

in order to open a document with an XPages, we have to call an url with following format :
http://server/database/name_of_xpage.xsp&documentID=xxxx
In one of my databases, the documents to open contain a "title" field.
I'd like to open the document by using an url like this : http://server/database/title_value
How to force the domino server to answer to such an url and to open the related XPage (like it's working on stackoverflow web site)

There are few options:
administrative solution - you can configure Domino to translate URLs at server level
XAgent, Form opening script, LotusScript agent - to redirect to correct URL
Form property to redirect to XPage, described below.
All you need is to make a view with short name or alias, "key" for example. First sorted column should contain your key value. Form property of every document should define XPage to open on web. Then url like this http://server/database/key/title_value will work. With one small caveat.

Create a web site substitution rule to redirect http://server/database/* to
http://server/database/yourxpage.xsp?openPage=*

You could create an XAgent (I called mine "open"), and take in smaller parameters to open the document. For example, let's say your main XPage "form" is called "xpDoc". Here is your XAgent (code in afterRenderResponse):
var val = context.getUrlParameter('title');
var nd:NotesDocument = database.getView('viewname').getDocumentByKey(val);
context.redirectToPage('xpDoc.xsp?documentId=' + nd.getUniversalID() + '?OpenDocument');
So, using this simple XAgent, you can use URLs to open documents, like so:
http://server/database/open.xsp?title=title_value
I just tried it out in a development db I have, and it seems to work pretty well. You can always make the XAgent name and "title" parameter smaller, to make the link smaller.
Take note that with this option, you won't need to update the NAB with any website rules. Since you want to link to documents, I'm assuming that you have more than a handful of documents in your application. Adding website rules in the NAB, I don't think, would be a good option as this would add a lot of extra maintenance. With the above method, everything can be done within your application.

Related

Kentico Form - Edit Form Action and Field Names

I have a form built in Kentico and want to change the form action to point to a marketing automation vendor website (eloqua) to process the form. I noticed that there's no way to change the Action on the Form app, so I thought of using js to replace the action dynamically. I'm not sure whether it'll work, but another immediate problem I have is the field name/id generated by Kentico is so long (> 70 characters - e.g. p$lt$ctl02$pageplaceholder$p$lt$ctl03$On_lineForm$viewBiz$Company$txtText) and exceeds the length allowed by the vendor. Is there a way to shorten those names/ids?
To clarify, the reason I need to edit the name because the vendor allows to map (copy/paste) html name to whatever name it's using. I've tried pasting the whole string from one Kentico field and got the error message of exceeding character limit.
First part of the question, how do i direct a form to submit to another site?
In ASP.Net, the only way is to use javascript to alter the 's action url. Since you want to be careful where you edit this, i would use jQuery to replace the "Submit" button on your form with a javascript function that will alter the form before submission (so you don't mess up other postbacks)
$("button.MySubmitButton").click(function() {
$("form").attr("action", "http://TheVendor.com/PostLocation");
});
Next question is to alter the field names. If you absolutely MUST have form element IDs sub 70 characters, you will have to use Javascript again and it will break any postback-related functionality of the elements, so make sure the form is "as is" before doing it.
Again there is security concern because when you post to another location, you are sending ALL the data, including hidden asp.net inputs that contain viewstates and the like. You may want to take the time to 'eliminate' right before you submit any field that you don't want sent to the other site.
Something like this (Test it out a bit first though)
$("input:not(id*='txtName'):not(id*='txtEmail'),select:not(id*='ddlQuestion')").remove();
As #trevor-j-fayas points out, you can use javascript to point a form action to another url. While this does work you may end up writing a lot of javascript to not only point the form to a new url but also to do some data massaging (changing id's, doing url formatting, etc) before sending it to the target.
Additionally you lose some of the benefits of using a Kentico Form because the data never actually gets submitted back to Kentico such as email alerts.
I have worked in a similar scenario where were we sending data to Eloqua but instead of doing it client side we did it from the server by using either:
The OnOnAfterSave event on the BizForm control itself
The global BizForm submit hook BizFormInfo.TYPEINFO.Events.Insert.After
After the form is submitted to Kentico, our custom hook code runs which sends the data to Eloqua. In either hook you can fully access the Form metadata, field names, and submitted values. You can then craft an HTTP POST request and submit it asynchronously using a class such as HttpClient.
Is not a good idea from the architecture stand point and most likely not going to work without opening a huge hole in their vendor web site security. First of all how are they going to process the from if they don't know the field names, what if form fields change etc. Secondly you going to run into hell of trouble trying to submit form one site to another etc. What if the vendor site is not responding etc.
What you need to do is submit the form back to kentico web site i.e. process it on kentico web site and send email notification with results to marketing automation vendor website (the easy way for now) and redirect user to vendor web site.
Redirection and email - you can do out of the box without any programming. Actually to do all the above requires no programming and you get all the information recorded on your Kentico site.

Associate 2 pages' analytics datas

I have a page with this url : example.com/someurl.
For some reason, I made a 301 redirection on it to example.com/some-url
But I would like to make sure that ancient datas for the first url will be associated with my new url.
Because if I export my datas, I'll have two entries which means two different pages, but actually this is only one page.
Thank you :)
Alas this doesn't work to well. Your best chance would be to use virtual pageview and pass in the old url to the pageview tracking on the new page:
ga("send","pageview","/some-url");
Alternatively you can create a filter in your GA view settings that rewrites the new url to the old url.
This will work for newly incoming hits. Data that's already connected will not change, and you cannot really consolidate after the fact.
You can use filter in settings
Filter Type: Search and Replace
field request URI
Search String: /some-url
Replace String: /someurl
And its merge wtih historical data

Hide the long URL when opening or editing Xpages

Is it possible to hide the URL of the action of opening or editing a document in a XPage?
I am trying to avoid this:
http(example)://notesdev1.my_company.com/po/po.nsf/%24%24OpenDominoDocument.xsp?databaseName=CN=My_Company_NotesDev1/O=HCI!!PO%5CPO-data.nsf&documentId=E879C68A9A88F6DD87257BC6005A0748&action=editDocument"
I don't think you can use site documents for URL's that open specific documents. I started out customizing the 'Default Action' and 'Document id' of the Document data source. I then switched and tried rebuilding the URL in the beforePageLoad event, and using context.redirectToPage but it still shows the long URL.
I would like to know if I can have control over the entire URL, and still direct pages as I see fit. I know that I can't stop a user from Bookmarking, but if I can control the URL, I can prevent the user from bookmarking intermediate steps in a wizard, and also avoid ugly URLs.
You can use a website document to mask those long urls. Your short url needs to have the DocId visible and then you can map it by a substitution rule.
The other option is to compute your data source. You set it to ignore request parameters and use your own:
http://yourserver/some.nsf/thexpage.xsp?doc=unid
Then use the context to retrieve the Unid and compute

XPages RichText Links

I have an XPage to display document data. To display RichText data I added a RichText control. What I found out is that database / view / document links are displayed with the appropriate icon but are converted to http-links. I would like to have these links being transformed to notes://-links to make sure that these links are being opened in the user's notes client rather than in the user's browser.
Any suggestions how to accomplish this from a technical point of view?
Many thanks in advance for your help.
Michael
Speak after me:
The web knows no RichText, it is a ghost of Christmas past.
There is only MIME. Now go and live with it!
Unless you build an hybrid application where RichText is used in the client and browser I recommend to select the option [x] Save as MIME in the RichText options. For hybrid applications it depends on the use case.
In your case it seems (?) that the datbase/view/document links are added using a client. It looks like a good idea to use mime in this case. Then is is just a simple string (of HTML) where you can before display (or save) use a DOM operation or a Regex to sort out the content. That works client or server side
You could have a custom control that contains a DIV and a XSP.addOnLoad() script that uses the RichtText url in an Ajax call and a dojo.query("a") to get a handle on all links and then sort out the ones you want to alter.
Let us know how it goes.

Sharepoint 2010 search: How to modify search query before submit (programmatically?)

I'm making a custom search box Web Part, similar to the OOTB Web Part from SharePoint
(SearchBoxEx class).
I'm interested in modifying the search query with additional text before it is submitted, based on a custom checkbox added on the Web Part.
Any help on how I can achieve this?
UPDATE:
I've used the AppendToQuery and AppQueryTerms properties, but this will rewrite the text in the search box as well. I'm interested in passing the values "in the background", maybe as an extra parameter. Point is that the query modification should happen without the user seeing it explicitly.
In the core result webpart there is a property where you can append text to the query and you will not see that in the textbox.
Best,
Bibhu
I when I had to customize People Search, I opted to roll my own web part and just called Response.Transfer to the Results.aspx and appended query string parameters to the URL. This wasn't the most elegant solution, but it was a quick way to modify the query "behind the scenes."
I'm sure you could develop an application page and set it as the Search Box web part's Results page. Put your custom logic in the page_load and then transfer (or do a form POST) to the actual results.aspx page.
I'm now developing an Extension of SearchBoxEx myself, and I'm currently trying to figure out how to call the base method that submits the query too. This blog shows how to call the internal CreateAdvanceSearchLink method of the SearchBoxEx class: http://pholpar.wordpress.com/category/search/

Resources