0

I have an xhtml page and i want to call a javascript function in a4j:commandLink. I dont know why but the javascript method is not called. I have tried writing function into .js file using "ui:define", but still i am not able to call that method. Is this is something because it is not falling into the life cycle.

The xhtml page is as follows:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:rich="http://richfaces.org/rich"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:h="http://java.sun.com/jsf/html">

<h:head>
<script type="text/javascript">
function myFunction(){
    alert("Hello World!");
    }
</script>
</h:head>
<h:body>
    <h:panelGrid columns="2">
        <h:outputText value="Choose the produce type:" />
        <rich:inplaceSelect value="#{selectedBean.currentType}"
            valueChangeListener="#{selectedBean.valueChanged}"
            defaultLabel="Click here to select">
            <f:selectItems value="#{selectedBean.firstList}" />
            <a4j:ajax  event="change" reRender="items, label"
                ajaxSingle="true"  oncomplete="myFunction()"/>
                <a4j:log></a4j:log>
        </rich:inplaceSelect>
        <a4j:outputPanel id="label">
            <h:outputText value="Choose concrete product:"
                rendered="#{not empty selectedBean.secondList}" />
        </a4j:outputPanel>
        <a4j:outputPanel id="items">
            <rich:inplaceSelect value="#{selectedBean.currentItem}"
                rendered="#{not empty selectedBean.secondList}"
                defaultLabel="Click here to select">
                <f:selectItems value="#{selectedBean.secondList}" />
            </rich:inplaceSelect>
        </a4j:outputPanel>
    </h:panelGrid>

</h:body>

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
5A9U
  • 15
  • 1
  • 2
  • 7

1 Answers1

-1

Add semicolon when you are calling java script function.

oncomplete="myFunction();"
Mr.Q
  • 4,316
  • 3
  • 43
  • 40