It's quite common to use embedded view in notes application but many of Lotus Notes developers don't find easy and efficient for web based application.I was going through Notes/Domino 6 and 7 Forum and found similar problem to one of the developer. She wanted to display a combobox (which refers to docs in a view on the database) to show only selected docs in an embedded view. e.g. category = "Finance".

http://www-10.lotus.com/ldd/nd6forum.nsf/DateAllThreadedweb/b03202c47143f47b8525761e0067fe74?OpenDocument

She didn't got satisfactory answer so created another post saying , She wanted to refresh an embedded view based on the value of a combobox on the web.

http://www-10.lotus.com/ldd/nd6forum.nsf/DateAllThreadedweb/66a335842154b86c8525761f0060073b?OpenDocument

So question is why should we use embedded view in web based application ? , Does it really required ? Can't we achieve similar functionality using ajax ? Don't you think we should break the trend which was started in Notes 5 era ?

Actually I never used embedded view in any of my web applications.I prefer AJAX instead of embedding view because it's fast and interacting well to the end user.

Let's have a look to simple requirement where you've to provide List box to the user where he can select multiple orders and can view their details. There could be many ways to achieve this but what could be the elegant way to make users WOW .. It's AJAX.
Here is the sample,



Here are simple steps to get rid of embedded views in web applications,

Step 1: Create a single column lookup view with following column formula,


orderNo + "|" + @Text(@DocumentUniqueID)


Step 2: Write dbcolumn in combo box to populate order numbers.

Step 3: On "View Order" button click write JavaScript to retrieve Document UNID and pass them to AJAX function.


//--------------------------------------------------------------------------------
var orderID="";
var sep="";
for(i=0; i<=document.forms[0].OrderSelection.length-1; i++) {
if ( document.forms[0].OrderSelection.options[i].selected ) {
orderID = orderID +sep+document.forms[0].OrderSelection.options[i].value;
sep="^";
}
}

displayOrder(orderID);
//--------------------------------------------------------------------------------
function displayOrder(orderID){
url= location.href;
tmpurl = url.substring(0,url.indexOf(".nsf"))
agentUrl= tmpurl+".nsf"+"/displayOrder?OpenAgent"
argsParam=trim(orderID);
runAgent(agentUrl,argsParam);
}
//--------------------------------------------------------------------------------
function runAgent(agentUrl,argsParam) {
req = false;

if (window.XMLHttpRequest) {
try {
req = new XMLHttpRequest();
} catch(e) {
req = false;
}
} else if(window.ActiveXObject) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
req = false;
}
}
}

if (req ) {
req.onreadystatechange = processReqChange;
req.open("POST", agentUrl, true);
req.send(argsParam);
}
}
//----------------------------------------------------------------------------------
function trim(str) {
return str.replace(/^\s+|\s+$/g, '');
}
//----------------------------------------------------------------------------------

function processReqChange() {
if (req.readyState == 4) {
if (req.status == 200) {
document.getElementById("status").style.display="none" ;
xmlStr=req.responseText
if ( xmlStr == 0 ) {
document.getElementById("status").innerHTML="Error in retrieving order";
return false;
} else {
document.getElementById("Contents").innerHTML=xmlStr;
}
} else {alert("There was a problem retrieving the XML data:\n" + req.statusText);}
}
}
//-----------------------------------------------------------------------------------

Step 5: In your Lotus Script agent use "Request_Content" CGI method to retrieve POST arguments. Write your business logic , Build custom HTML and return them using Print method.Don't forget to set content-type as per your logic ( Text, HTML or XML ). Code can be,


Sub Initialize

Dim s As New NotesSession
Dim curDb As NotesDatabase
Dim view As NotesView
Dim curDoc As NotesDocument, doc As NotesDocument
Dim args As String
Dim HTML As Variant,ret As Variant

Print "Content-Type:text/html"

On Error Goto errHandler


Set curDoc=s.DocumentContext
Set curDb= s.CurrentDatabase
Set view = curDb.GetView("vwOrder")
args=curDoc.Request_Content(0)



Print HTML

Exit Sub
errHandler:
Print "0"
Exit Sub
End Sub


There are best ways to design Lotus Notes applications robust and as powerful as dot net and Java, Don't let others say "Notes systems are ugly".It's just our efforts which can lead Notes market as high as It was 10 years ago..

2 Responses to "Web applications and embedded view"

  1. gravatar Lauraine Says:

    Thanks for the post. I liked it. Keep going I follow you.
    Android app development| Android app developer|

  2. gravatar Lauraine Says:

    I have no words for this great post such a awe-some information i got gathered. Thanks to Author.
    Android apps development| Google android app development|

Leave a Reply

preload preload preload