tags:

views:

22

answers:

1

I have the following link in one of my JSPs. When an user clicks on that link I'm calling an action in my backing bean. I need to show a JavaScript alert message based on the response of that action.

<h:commandLink onclick="setSelectedClientAndFund();" id="next"
  action="#{fyeSelection.getFYEReportHome}">
    <h:graphicImage value="../images/NextBT.png"></h:graphicImage>
    <a4j:loadScript src="alert('hello');"></a4j:loadScript>
</h:commandLink>

How can I achieve this?

A: 

Just render the script conditionally.

<h:outputText value="<script>alert('hello');</script>" escape="false" rendered="#{bean.show}" />
BalusC
Hi thx for help now i'm able to show the script message but the script message is coming at the time of page initial load i want show it once completion of page load the script message should be conformation message if user clicks again "yes" i need to call another bean action how can i achieve this Please help in this
Just control the `rendered` outcome accordingly.
BalusC
could u please explain clearly.
When `rendered="false"` the script won't be printed (and thus won't be executed). When `rendered="true"` then the script will be printed and executed. You need to ensure that `bean.isShow()` returns false during page initial load.
BalusC