Thursday, June 24, 2010

Accessing Javascript variable from the Java file(backenbean) in JSF

In JavaScript:
function clntCookie(){
var sesid = document.cookie;//this will give client sessionid and stores in sesid variable
document.getElementById("tf_CheckValue").value = sesid;//assigning sesid value to the tf_CheckValue which is inputhidden field
}
In JSP:
<h:outputText id="text" value=" ">
<h:inputHidden id="tf_CheckValue" value="#{pendingApplication.tf_CheckValue}"/>
</h:outputText>
place the above code under <h:form> tag

In java (backenbean) file:
private String tf_CheckValue = new String();//generate set and get methods
String sesval = getTf_CheckValue();//this will get the client session id from javascript and place in the sesval.

JSF Related topics: JCaptcha in JSF, Integrating Richfaces with JSF,Getting client and server sessionId in JSF,PopUp AlertMessagebox for JSF and more.....

No comments:

Post a Comment