• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

JSF rendered javascript issue

 
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
 
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 = '<h:outputText 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>
.
.
.
 
Popeye has his spinach. I have this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic