Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF rendered javascript issue

 
Richard Roszak
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my JSF app I have a popup executed from one of my pages. The popup allows the user to select rows and when the import button is depressed the selected rows are added to the main page and the popup closes. I need to call a javascript to set a flag if any rows are added. I can check in the bean to see if any records are selected. I just require a way of calling my javascript when the page is rerendered.

Is there a way of adding a javascript call in a rerendered?

Thanks

Richard
 
Smitha H Rao
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSF components gets rendered from server and javascript function gets called at client side.
So If you want to set a javascript variable when the page is rendered/loaded, you can simply do it in <body onLoad="" function.

>
 
Richard Roszak
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I understand but I only want my javascript called if in the Bean I have a certain value set. Not sure how I can do that?

Thanks

Richard
 
Smitha H Rao
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had same requirement in one of my pages and I did as below:

set a bean property if you want to call javascript function and then assign it to a javascript variable as below:

<script language='javascript'>

var rowFlag = '<hutputText value="#{bean.property}" />';

// your function goes here
function myFunction(){
}

// now on the basis of the rowFlag you can call myFunction()
if(rowFlag == 'Some Expected value')
myFunction();

</script>

<body>
<f:view>
<h:form>
.
.
.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic