• No replies
1569 Posts

Pinned topic Problem in triggering ajax call using JSF 1.1 on Websphere portal 6.1

‏2012-07-30T17:38:35Z |
Hi All,
I am trying to generate random numbers continuously while the page loads. This is a Proof of concept that i am trying to achieve before getting started to work on a business requirement. I have an output text which displays the generated random numbers by calling the backing bean. What the behaviour i am expecting is, I want the backing bean's getRandomNumberInt() to be called continuously so that i see the random numbers getting changed on the page.

Any help would be appreciated. Below is the code snippet.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">

<hx:scriptCollector id="scriptCollector1">
<h:form styleClass="form" id="form1">

<h:panelGroup styleClass="panelGroup" id="randomNumberGroup">
<h:outputText styleClass="outputText" id="randomNumber"
<hx:ajaxRefreshRequest target="randomNumberGroup"

<h:outputLink id="outPutLinkMoreRandomNumber">
<h:outputText id="randomNumberOutputTextId"
value="Fetch more Random Number">
<hx:behavior event="onload" id="behavior1" behaviorAction="get"

</hx:scriptCollector> - Backing bean

public class AjaxEnabledPOCView extends PageCodeBase {
private double randomNumberInt = 0;

public double getRandomNumberInt() {
randomNumberInt = randomNumberInt + Math.random();
System.err.println("Random Number: -" + randomNumberInt);
return randomNumberInt++;

public void setRandomNumberInt(double randomNumberInt) {
this.randomNumberInt = randomNumberInt;