wood burning stoves*
The moose likes JSF and the fly likes JSF rendered javascript issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF rendered javascript issue" Watch "JSF rendered javascript issue" New topic
Author

JSF rendered javascript issue

Richard Roszak
Greenhorn

Joined: Jan 06, 2009
Posts: 27
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

Joined: Oct 20, 2007
Posts: 50
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.

>


Free Mock tests Interview questions
Richard Roszak
Greenhorn

Joined: Jan 06, 2009
Posts: 27
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

Joined: Oct 20, 2007
Posts: 50
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>
.
.
.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF rendered javascript issue
 
Similar Threads
Passing JSF request Object
javascript method called in jsf page, in dataTable.
How to disable rich:listShuttle controlling components?
a4j and javascript interaction
Jsf rerender using javascript