Friday, April 27, 2012

website tracking in php

Yes really php is a efficient and nice user friendly tool for scripting.

I was in a job to track a website. And also word press form is my front- end. The site is in php.

So session variables is not possible to track. Because we can not retrieve the session variable in client side javascript. I have planned to set cookies for all tracked information using php. That is cool. I have written that in javascript. But I am not able to get the IP address in an efficient manner.
Please view :-
http://kramkumarmca.blogspot.in/2012/04/cookies-javascript-function-altest.html

Here I am tracking my blog info. It is 20% of requirement. In javacsript, referrer makes me fool for some browser. And also there is no direct way to get the IP address of the visitor. We are in need of going some external provider.

So I moved to php. Using the CGI variable,we can easily manipulate the tracking info effectively.

Please view CGI variable in Xpage :- http://php.net/manual/en/reserved.variables.php

Yes really wondered, Job done in right manner. right way. No Issues till now.




Splitting a string in xpage

Hi,

Actually I had an issue with splitting the string. But that string can have null character.
That time I was in server side javascript on Xpage.
I had used @Explode(",,test,test123").length, it should return 4 as of my concern.
But the above had returned 2. Again I had used split(",,test,test123"), I thought it would work perfect.
Again I got cheated by Xpage :).
So I used the split(",,test,test123") in CSJS. I got my thing correct.

Obviously what we have known that the functional behavior is changing, while running the split in Domino server.

Try to use basic javascript in our xpages at CSJS script. Do not use it in SSJS script.

Monday, April 23, 2012

Cookies - Manipulation using javascript

Website Tracking(Lead's Info.,) cookies - javascript


Referer URL:
IP ADDRESS :
Referrer's Domain :
Search Key :
Landing Page :
Tracking Address :
Alert Button :
Delete Cookies:

Tuesday, April 17, 2012

Get all the Design Elements - NotesNoteCollection

Everyone had this experience on their first exercise that getting the design element names.

We have two different ways.,

1. STEP- 1 : For getting the design elements name in our own view.

2. We can get it from NotesNoteCollection. Actually I tried to get the DXL (DOM object) from one of my non accessed database. Their I remembered the thing which I suffered in my past. Use of NotesNoteCollection is easy.

Please follow this code:-


On Error GoTo e
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim stream As NotesStream
Set stream = session.CreateStream
Dim filename As String
filename$ = "D:\dxl\" & Left(db.FileName, Len(db.FileName) - 3) & "dxl"
If Not stream.Open(filename$) Then
Messagebox "Cannot open " & filename$,, "Error"
Exit Sub
End If
Call stream.Truncate

REM Create note collection for current database
Dim nc As NotesNoteCollection
Set nc = db.CreateNoteCollection(False)
'Call nc.SelectAllDesignElements(True)
nc.SelectForms=true
Call nc.BuildCollection
Dim nid As String
nid=nc.Getfirstnoteid()
MsgBox nc.count
For i=1 To nc.Count
Dim doc As NotesDocument
nextid=nc.Getnextnoteid(nid)
Set doc=db.Getdocumentbyid(nid)
MsgBox doc.Getitemvalue("$Title")(0)
nid=nextid
Next
REM Export note collection as DXL
Dim exporter As NotesDXLExporter
Set exporter = session.CreateDXLExporter(nc, stream)
Call exporter.Process
MsgBox "Finished :)"
Exit Sub
e:
MsgBox "Error : " &Error &Erl() &" -- " &Err
Exit sub


The above is used to get the names of our forms in current database,

Monday, April 16, 2012

400- Bad Request Xpages

I was in free. So I thought to give the user name and password in url to my Domino server.

I thought domino is terrifically have the security. So searched any way is there.

Finally I have traced the cookies and gave the user name and password on url.

But I got the following Error.

Http Status Code: 400

Reason: Http request contains a malformed escape sequence

I searched the solution for rectify or overcome this...

Yes We can if we set

HTTPAllowDecodedUrlPercent=1

in Notes.ini on your corresponding server. This will make the funny thing that I have mentioned above, :)

Message box in server using Lotus script

Some of the time we need the prompt while running an agent in server.

But everyone easily tell that it is not possible on Lotus script.

But we can. We have print statement in lotus script. It is very powerful statement and also here we can use javascript code itself. The following will throw the message box while running an agent in server.

Code:-
Dim alertMsg As String
Print {<script language="JavaScript" type="text/javascript">}
Print {alert('Ramkumar')}
print {</script>}

Web service in Lotus script

Simply we can provide and consume the Web Service using Lotus Script.

Step 1:
Create the web service provider as firstWebservice.

Step 2:
Write the following class in it.

class first

Function messgae
message="Hai..."
End Function

End class

Step 3:
Web service provider property, Do the following...


Step 4:
Create a button at which you want to consume this web service.
Write the following code in it.

Code:

Dim v As Variant
Set Client =CreateObject("MSSOAP.SoapClient")
Call Client.mssoapinit ("URL OF DATBASE/Web Service Provider Name?WSDL")
Msgbox Client.message

Thursday, April 12, 2012

calling java script Library from Lotus script

Hi, Just I have reminded the things when I was as Trainee.

I have tested the javaObject. But now I got an issue with script Library - java.

Each time when I change the Script Library I need to delete the cache.

Step 1: Create Script Library as Name as "Java"

Use the code as follow,

public class Test {


public int x;
public int add(int a, int b)
{
return a+b+x+100;
}

public Test(int c)
{
x=c;
}
}


Step 3: Create a new form and put one button there,

In Button option -> put Uselsx "*javacon" and use "Test"

Step 4: Use the code as follow in that button.,

On Error Goto e
Dim mySession As JavaSession
Dim myClass As JavaClass
Dim myObject As JavaObject
Set mySession = New JavaSession()
' Get Java "java.lang.Integer" class
Set myClass = mySession.GetClass("Test")
' Create a "java.lang.Integer" object
Set myObject = myClass.CreateObject("(I)V",20)
Msgbox myObject.add(1,2)
Exit Sub
e:
Print "Error : " &Error &Erl()
Exit Sub


If you change the Script Library, You will get the problem as I mentioned in above.

Wednesday, April 11, 2012

Extension Library in Xpage

Successfully I did my first Extension Library control today.

Customized control using java facescontext.

Thanks to Extension Library



Dynamic Table - And Getting the Row values from Repeat control

Can we get the repeat control control's row value?

Dynamically we can get using Client Side Java script in Xpage.

With the use of Repeat control we can create dynamic rows of field.

And We can use a Pager for creating nice UI.

Also we have CSJS functionality for retrieving the values...

Please find the code as below.,

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

<xp:this.beforePageLoad><![CDATA[#{javascript:sessionScope.dynaField=parseInt("1")}]]></xp:this.beforePageLoad><xp:div style="text-align:center">
<xp:span style="font-weight:bold;color:rgb(0,0,255);font-size:16pt">Ramkumar's Dynamic Row Generation</xp:span>
</xp:div><xp:div style="text-align:center"></xp:div>
<xp:panel id="Panel_All" style="text-align:center">

<xp:pager layout="Previous Group Next" id="pager1" for="repeat1"
panelPosition="top">
</xp:pager>
<xp:repeat id="repeat1" var="test" indexVar="index"
value="#{javascript:parseInt(sessionScope.dynaField)}" rows="8"
style="border:1pt">


<xp:table style="width:100.0%">
<xp:tr>
<xp:td
style="border:1pt;width:32.0%;text-align:center">
<xp:inputText id="inputText1">
<xp:this.defaultValue><![CDATA[#{javascript:return getComponent("repeat1").getValue()}]]></xp:this.defaultValue>
</xp:inputText>
</xp:td>
<xp:td style="border:1pt;text-align:center">
<xp:inputText id="inputText3"></xp:inputText>
</xp:td>
<xp:td style="border:1pt;text-align:center">
<xp:inputText id="inputText4"></xp:inputText>
</xp:td>
</xp:tr>
</xp:table>
</xp:repeat>



<xp:br></xp:br>


<xp:br></xp:br>
<xp:table style="width:100%">
<xp:tr>
<xp:td rendered="false">
Number of Field You have added :
</xp:td>
<xp:td style="display:none">
<xp:inputText id="inputText2"></xp:inputText>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td colspan="2" style="text-align:center">
<xp:button value="ADD FIELD" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="Panel_All">
<xp:this.action><![CDATA[#{javascript:sessionScope.dynaField=parseInt(sessionScope.dynaField)+1
getComponent("repeat1").setValue(parseInt(sessionScope.dynaField));
getComponent("inputText2").setValue(parseInt(sessionScope.dynaField));}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button value="REMOVE FIELD" id="button2">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="Panel_All">
<xp:this.action><![CDATA[#{javascript:sessionScope.dynaField=parseInt(sessionScope.dynaField)-1
getComponent("repeat1").setValue(parseInt(sessionScope.dynaField));
getComponent("inputText2").setValue(parseInt(sessionScope.dynaField));}]]></xp:this.action>
<xp:this.script><![CDATA[var t=document.getElementById("#{id:inputText2}").value;
if(t==0 || t=="0")
{
alert("You can not do this opertion");
return false;
}]]></xp:this.script>
</xp:eventHandler>
</xp:button>
</xp:td>

</xp:tr>
</xp:table>
<xp:br></xp:br><xp:button value="Get the Repeat Control Value" id="button4" style="width:200.0px">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[try
{
var row=window.prompt("Please Enter the Number of Row");
row=row-1
var id1="view:_id1:repeat1:"+row.toString()+":inputText1"
var id2="view:_id1:repeat1:"+row.toString()+":inputText3"
var id3="view:_id1:repeat1:"+row.toString()+":inputText4"
var val=document.getElementById(id1).value.toString() +", "+document.getElementById(id2).value+", "+document.getElementById(id3).value
alert(val)
}
catch(e)
{
window.prompt("Please Enter the Valid Column")
}]]></xp:this.script>
</xp:eventHandler>
</xp:button></xp:panel>
<xp:eventHandler event="onClientLoad" submit="true"
refreshMode="norefresh"></xp:eventHandler>
</xp:view>

Thursday, April 5, 2012

Invoking onClick enent in SSJS in Xpage

We can invoke the Event of a button using SSJS...

Normally we used CSJS for this action.

Code as follows

document.getElementById("ID").click()


But same we can do in SSJS also...


getCompoenent("ID").getOnclick()

Wednesday, April 4, 2012

Different way to get the ViewPanel's Row Value

We have a method- getChildren(), It is used to get the children of our DOM object.

Basically our xpage's back-end code is a DOM object. So we can get the element's value via tree structure. So Everything in our viewPanel is a hierarchy.

We can get viewColumnValue via this tree structure.


var row= getComponent("viewPanel1").getChildren().toArray();
var va="";
for(var i=0;i {
va=va + " - "+ row[i].getValue();
}
return va

Dynamic Table creation Xpages

In Xpage is a very powerful and efficient tool.

Here we can use ajax directly[Manually] not in code.

I tried to make a Dynamic rows today,

I thought it is difficult to get the item value for that dynamic rows,

But we can easily fetch and we can easily retrieve the value for those dynamic fields.

I used a repeat control., This is very powerful component in Xpage,

Here we can iterate the value of the repeat control use of single line code.


Code:-


<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

<xp:this.beforePageLoad><![CDATA[#{javascript:sessionScope.dynaField=parseInt("1")}]]></xp:this.beforePageLoad><xp:div style="text-align:center">
<xp:span style="font-weight:bold;color:rgb(0,0,255);font-size:16pt">Ramkumar's Dynamic Row Generation</xp:span>
</xp:div><xp:panel id="Panel_All">
<xp:repeat id="repeat1" rows="30"
value="#{javascript:parseInt(sessionScope.dynaField)}">

<xp:table>
<xp:tr>
<xp:td style="border:1pt">
<xp:inputText id="inputText1"></xp:inputText>
</xp:td><xp:td style="border:1pt">
<xp:inputText id="inputText3"></xp:inputText>
</xp:td>
<xp:td style="border:1pt">
<xp:inputText id="inputText4"></xp:inputText>
</xp:td>
</xp:tr>
</xp:table>
</xp:repeat>

<xp:pager layout="Previous Group Next" id="pager1"
for="repeat1">
</xp:pager>

<xp:br></xp:br>

<xp:table>
<xp:tr>
<xp:td>Number of Field You have added :</xp:td>
<xp:td>
<xp:inputText id="inputText2"></xp:inputText>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td colspan="2" style="text-align:center">
<xp:button value="ADD FIELD" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="Panel_All">
<xp:this.action><![CDATA[#{javascript:sessionScope.dynaField=parseInt(sessionScope.dynaField)+1
getComponent("repeat1").setValue(parseInt(sessionScope.dynaField));
getComponent("inputText2").setValue(parseInt(sessionScope.dynaField));}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button value="REMOVE FIELD" id="button2">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="Panel_All">
<xp:this.action><![CDATA[#{javascript:sessionScope.dynaField=parseInt(sessionScope.dynaField)-1
getComponent("repeat1").setValue(parseInt(sessionScope.dynaField));
getComponent("inputText2").setValue(parseInt(sessionScope.dynaField));}]]></xp:this.action>
<xp:this.script><![CDATA[var t=document.getElementById("#{id:inputText2}").value;
if(t==0 || t=="0")
{
alert("You can not do this opertion");
return false;
}]]></xp:this.script>
</xp:eventHandler>
</xp:button>
</xp:td>

</xp:tr>
</xp:table>
<xp:br></xp:br>
</xp:panel>
<xp:eventHandler event="onClientLoad" submit="true"
refreshMode="norefresh"></xp:eventHandler>
</xp:view>

Tuesday, April 3, 2012

Introduction to Lotus Notes

NICE SITE BY IBM ABOUT NOTES... YOU CAN SEND YOUR FEEDBACK HERE.


Overall about Notes

invoke onClick event in Xpage

At one point of time, I was in need of invoke the onClick event while clicking a button.

So I have googled and get the simple way.,

document.getElementById("#{id:button2}").click()

button2's click event will be triggered.

Terrific SSJS in Xpage

Here is an interesting stuff.

But it is one of the worst thing in Domino.

We can guide any server using the following code...

session.sendConsoleCommand(serverName, Command)

Wondering Evaluate in Xpage - @Formula in Xpage

I had a problem with finding a business day for an Leave Management Application,

 I was very new with Xpage, and I don't  know whether the session is working on our server. But Now I got an idea to calculate the Businessdays in efficient manner.

Note: That time I have calculated business days using CSJS, It exceeds more than 50 lines of coding. Because of the requirements and getting the Leave dates depends on different Location basis.

But now I got an interesting command in Xpage SSJS,

session.evaluate() is reducing our time and risky.

Here we can use our @formula, It is similar to @Eval.

"Not Case sensitive" - Nice Feature for Lotus notes developer.

Who told Notes is worse than other Language. No other language has a functionality like this.

see this link:- (Hard in JS)

Calculate B'Day[Exclude Sat and Sun]

Monday, April 2, 2012

Run your Domino Console Commadn on Your Designer

The following command is used to run your console command and return the console details on your Xpage.

Try it, Just put a following piece of code into default value of your Multi-line edit box.

session.sendConsoleCommand(serverName,command)

Same thing is in Lotus script too... :)