Showing posts with label javascript. Show all posts
Showing posts with label javascript. 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.

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:

Wednesday, April 11, 2012

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()

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.

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]

Wednesday, March 28, 2012

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"
}