Friday, December 30, 2011

Dbcolumn for LotusScript

We have a very easy method to get the column values of our view(@dbcolumn).

getcolumnvalues(0) - Returns First column Values
getcolumnvalues(1) - Returns Second column Values

Like C array...

Code:

Dim session As
New notessession
Dim db As NotesDatabase
Dim vw As
notesview
Set db=session.CurrentDatabase
Set
vw=db.GetView("VwName")
Forall a In
vw.GetColumnValues(0)
Msgbox a
'similarly we can get Dbcolumn
End Forall

The Above code
displays the First column values...

How to generate the PDF using javaagent

Here I have four field in an document...

I have known that field's name...

I can generate the PDF document using pdfWriter class in java...

The below javaAgent is used to generate the PDF document in our given location.


public class JavaAgent extends AgentBase
{
public void NotesMain()
{
try
{
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Document docpdf = new Document();
Database db=session.getCurrentDatabase();
View vw=db.getView("vw_employeeDatails");
try
{
//create a document
PdfWriter.getInstance(docpdf, new FileOutputStream("E:\\New Folder\\CreatePDFInlotus.pdf"));
//open doc for r/w
int i=1;
docpdf.open();
while(doc!=null)
{
String testName=doc.getItemValueString("name");
String dept=doc.getItemValueString("department");
String des=doc.getItemValueString("designation");
Vector mob=doc.getItemValue("mobno");
String mobn=mob.toString();
docpdf.add(new Paragraph ("\n"));
docpdf.add(new Paragraph ("Value : "+i));
docpdf.add(new Paragraph (testName));
docpdf.add(new Paragraph (dept));
docpdf.add(new Paragraph (des));
docpdf.add(new Paragraph (mobn));
i++;
doc=vw.getNextDocument(doc);
}
// Code updated
}
catch (DocumentException de)
{
System.err.println(de.getMessage());
}
docpdf.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

Get the Selected documents in a View on WEB (Xpage)

With the use of getSelectedids, We can get the notesid of all selected documents...

After getting the id collection, We can handle the document use of Database class...

Sample code:

var vpane=getComponent("viewPanel1");
var arr=vpane.getSelectedIds();
var db=session.getCurrentDatabase();
var name;
var des;
var i;
if(arr.length>0)
{
for(i=0;i<arr.length;i++)
{
if(arr[i]!="")
{
var docid=arr[i];
getComponent("count").setValue(docid.toString());
var doc:NotesDocument=db.getDocumentByID(docid.toString());
doc.putInFolder(“folderName”);
}
}
}

Video in Xpage

With the use of embed tag and object tag we can import video or flash file into our

xpage...
Example for embedtag: Put the following tag into our xpage source
embed src="somefilename.swf" width="550" height="400"
embed

similarly for , But this is for flash file only...
object

codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.c

ab#version=9,0,115,0" data="C:\Documents and Settings\maarga_trainees\My

Documents\choudanse7.swf"
type="application/x-shockwave-flash"

How to find the running environment of X-pages

Here I am going to tell that current X-page is running Whether in notes or client. Using that information we can visible or disable a control depend upon running environment.

Her i give a simple example that if running environment is notes means that label shows "Notes " else it shows "WEB"
xp:label id="label1"
[CDATA[#{javascript:
if( context.isRunningContext('Notes') ){
return "Notes ";
}
return "WEB ";
}]]> /xp:this.value

/xp:label