Showing posts with label Xpages. Show all posts
Showing posts with label Xpages. Show all posts

Monday, December 3, 2012

JSF in Xpages

We can handle the servlet objects in xpages very effectively.

In xpages, JSF's facesContext is having the capablity to do this action. Actually this is fetching the CGI variables from server.

Long back I had one assignment, that time I used php for getting the CGI variables from server. I was not aware of this facesConetext at that time. But now I came to know that Xpages have that capablity. Please follow the commands. It should useful for you.

facesContext.getExternalContext().getRequest().getAuthType();


facesContext.getExternalContext().getRequest().getContentLength();

facesContext.getExternalContext().getRequest().getContentType();

facesContext.getExternalContext().getRequest().getContextPath();

facesContext.getExternalContext().getRequest().isSecure() ? "ON" : "OFF";

facesContext.getExternalContext().getRequest().getPathInfo();

facesContext.getExternalContext().getRequest().getPathTranslated();

facesContext.getExternalContext().getRequest().getQueryString();

facesContext.getExternalContext().getRequest().getRemoteAddr();

facesContext.getExternalContext().getRequest().getRemoteHost();

facesContext.getExternalContext().getRequest().getRemoteUser();

facesContext.getExternalContext().getRequest().getMethod();

facesContext.getExternalContext().getRequest().getScheme();

facesContext.getExternalContext().getRequest().getRequestURI();

facesContext.getExternalContext().getRequest().getServletPath();

facesContext.getExternalContext().getRequest().getServerName();

facesContext.getExternalContext().getRequest().getServerPort();

facesContext.getExternalContext().getRequest().getProtocol();

facesContext.getExternalContext().getContext().getServerInfo();

facesContext.getExternalContext().getHeader("Cooike")
facesContext.getExternalContext().getHeader("Host")
facesContext.getExternalContext().getHeader("Referer")

We can find this in our discussion8.ntf.

Thursday, June 7, 2012

Sequence number generation in Replication copies

Very very funny, familiared and important issue. Mostly everyone has faced this issue. The issue is that, I am having the employee database on main server. And I have a lot of replica copies in different location. I need a exact sequence unique long needed. If replication copy's same document is modified in more than one different location then replication conflict occurs. And also the sequence number will get spoiled.  And some people used to say that this is easy but now only I have familiared with this. Only the people who have already faced this issue, will tell that it can not be solved. We have to manually resolve this.

Yes exactly, Project should be done with the customer requirements. No customer does like the rework.

Okay I come to point...

Before heading this issue we need to know about the "Replication conflict", "Replication", "Document Locking", "Developer's Responsibility [kidding]" :)

We have a lot of tool for handling this. But we are  third party for customer. If we purchased tool from third party then we have a third party for our tool. so sixth party for customer :) . No customer needs that relationship. And also the license period and other things may conflict with our agreement.

Again we come with document locking. We need to enable the Allow document locking in database property. And we have to enable the master server in ACL of the database.These are features of document locking.,

if the document is not locked, the method places the lock and returns True
if the document is locked and the current user is one of the lock holders, the method returns True
if the document is locked and the current user is not one of the lock holders, the method returns False
if the document is modified by another user before the lock can be placed, the method raises an error


But the user does not want the hard reworking. So I analyze for the solution on this issue.

But still I have not clear idea about this. But complex way is there, That is, we have to check all the replication servers and while user tries to edit the document for new document or sequence number creation we do not do it in replication server. Try to write a schedule agent for this.That will be the great idea. or Try to make a common sequence number format, Like Date + Location + Number , etc.,

For creating sequence number, funny this is too easy. Once fresher or new notes person needed, then reply me back

Friday, April 27, 2012

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:

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, :)

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

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... :)

Wednesday, March 28, 2012

Jquery in Xpage - HighChart

Everytime we used to go dojo chart for making the chart in Xpage...

But here is an easy way to make graph and Input translation functionality using Jquery.,

I foung this in Xomino site., It is very useful for chart making in Xpage...

HighChart in Xpage

How to generate Dynamic view Column - Xpages

Here is an one more old version of previous post Dynamic View Panel.,

I tried to generate the view column values dynamically., Yes it is very easy to do this.,

Here is code we can change the view column's value dynamically...

Iterate the following code will automatically generate the view column's value.,

c="viewColumn"+@Text(i+1);
getComponent(c).setRendered(true)
getComponent(c).setColumnName(t[i]);

Check box group vs Hash Map in Xpage

In Client side javascript, it is a powerful script language for manipulating our DOM object.

I have a check box group in Xpages. And I added a hashMap value into that check box group.

Ex:

key value
1 X
2 Y
3 Z

But I am not able to get the key's label name [1,2, 3]. I can get the X,Y,Z as values.

The following is the check Box group value in Xpage.,

<xp:checkBoxGroup id="checkBoxGroup1">
<xp:selectItem itemLabel="1" itemValue="X"></xp:selectItem>
<xp:selectItem itemLabel="2" itemValue="Y"></xp:selectItem>
<xp:selectItem itemLabel="3" itemValue="Z"></xp:selectItem>
</xp:checkBoxGroup>

But in backend HTML code is as follows...

<fieldset id="view:_id1:checkBoxGroup1" class="xspCheckBox"><table class="xspCheckBox">
<tr>
<td>
<label><input name="view:_id1:checkBoxGroup1" value="X" type="checkbox"> 1</input></label></td>
<td>
<label><input name="view:_id1:checkBoxGroup1" value="Y" type="checkbox"> 2</input></label></td>
<td>
<label><input name="view:_id1:checkBoxGroup1" value="Z" type="checkbox"> 3</input></label></td>
</tr>
</table></fieldset>

So I am not to get this via its children...

So i used parentNode for finding its label name.,

Try the following is used to get the values of checkBoxGroup's Key value...

var check= document.forms[0].elements["#{id:Column}"]
var label=null;
var value1=null;
alert("Test");
for(var i=0;i {

if(document.forms[0].elements["#{id:Column}"][i].checked)
{

label=label+","+((document.forms[0].elements["#{id:Column}"][i].parentNode.textContent))
value1=value1+","+(document.forms[0].elements["#{id:Column}"][i].value)
}
}

alert(label + "-- " +value1)

Dynamic View Panel in Xpage...

Here is an interesting stuff...

Like how can we generate a dynamic view in Xpages.,

I was tried to make the dynamic view panel since past two weeks...

I have seen and gone through the "http://www.jmackey.net/groupwareinc/johnblog/johnblog.nsf/…"

But the thing is here we can not get the value for null named column. And also this will work only within the scenario as column name and Programmatic Column name are equal.
And also they used composite Data for constructing view Panel.

Here I am getting the column values with the use of its column number.

But it is feasible to iterate a values of view column Entry.,

Here is an Example code., This will take your DB Name corresponding your current server...

Code:-

Code for Panel

getComponent("Panel1").getData()[0].setViewName(getComponent("view").getValue());
getComponent("Panel1").getData()[0].setDatabaseName(sessionScope.db);

Monday, March 26, 2012

How to use Jquery in xpage?

Jquery is very efficient for changing the visiblity and UI things...

It is very fast compare to our SSJS.,

Step 1:- Add the following url into Xpage -> resources -> Javascript Library...

"http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1.min.js"

Step 2:- Put the following code into your Xpage you wil find the nice animation and nice funtionality...

Thanks W3Schools

Code:-

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"><p></p>
<script type="text/javascript" src="jquery.js"></script><script type="text/javascript">
$(document).ready(function(){
$("#animate").click(function(){
<!-- $("div").fadeTo("slow",0.25); -->
<!-- $("div").fadeOut(4000); -->
<!-- $("#test").animate({left:"100px"},"slow");
$("#test").animate({fontSize:"3em"},"slow");
$("#test").animate({left:"100px"},"slow");
$("#test").animate({fontSize:"1.3em"},"slow"); -->

$("#hide1").animate({left:300},"slow");
$("#hide1").animate({right:300},"slow");
$("#hide1").animate({left:100},"slow");
$("#hide1").animate({right:100},"slow");
<!-- $(this).hide(); -->
});

$("#hide1").click(function(){
<!-- $("div").fadeTo("slow",0.25); -->
<!-- $("div").fadeOut(4000); -->

$("#test").html("W3Schools");
});

});
</script><xp:this.resources>
<xp:script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1.min.js" clientSide="true">



</xp:script>
</xp:this.resources><div id="test" style="background-color:yellow;height:100px;width:150px">
<xp:inputText id="inputText1" readonly="true">
<xp:this.value><![CDATA[#{javascript:"Hello "}]]></xp:this.value>
</xp:inputText>
</div>
<p id="animate">Click me to animate!</p>
<p id="hide1" style="position:absolute">Click me to hide!</p>


</xp:view>

HashMap in Xpages - CheckBox group many times will Issue.,

I got an Issue with checkBoxGroup in Xpage.,

I can add the value in checkBoxGroup and also I can retrive...

But the Label value I can not retrive...

I have used the following code for getting the keyvalue...

getcomponent("id").getAttributes().get("xxx")

getcomponent("id").getAttributes().values()

Each time I got failed...

Finally I got an idea to implement the HashMap with SSJS.,

In client side java script we can get the values very easily.,

But in server side Java script It is difficult.,

I am not teling It is Impossible. We can (Please tell If you can :) )

The following code will make some idea to use HashMap...

try
{
if((sessionScope.db !="" ))
{
var view12=getComponent("view").getValue();
var db=session.getDatabase(sessionScope.server,sessionScope.db)
var vw:NotesView=db.getView(view12);
var colName= vw.getColumnNames().toArray();
var count=0;
var listCount:java.util.HashMap=new java.util.HashMap();
if(listCount.isEmpty() == false)
{
listCount.clear()
}

while(colName.length>count)
{
listCount.put(count,colName[count]);
count++;
}
return listCount.keySet().toArray()
}
else
{
return ""
}
}
catch(e)
{
return "You did not choose any column"
}