var popup = AdfPage.PAGE.findComponent("popupId");
if (popup.isPopupVisible() == true){
popup.hide();
}
Wednesday, December 8, 2010
How to invoke a JavaScript method from the managed bean
Jspx part
---------------
<f:view>
<af:document id="d1">
<![CDATA[
<script>
function greeter() {
alert("Hello..");
}
}
</script> ]]>
<af:form id="f1">
<af:commandButton text="commandButton 1" id="cb2"
partialSubmit="true"
action="#{ScriptCallerBean.cb2_action}"/>
</af:form>
</af:document>
</f:view>
managed bean coding
------------------------
import javax.faces.context.FacesContext;
import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;
public void caller(){
ExtendedRenderKitService extRenderKitSrvc = Service.getRenderKitService(FacesContext.getCurrentInstance(),ExtendedRenderKitService.class);
extRenderKitSrvc.addScript(FacesContext.getCurrentInstance(),"window.greeter()");
}
---------------
<f:view>
<af:document id="d1">
<![CDATA[
<script>
function greeter() {
alert("Hello..");
}
}
</script> ]]>
<af:form id="f1">
<af:commandButton text="commandButton 1" id="cb2"
partialSubmit="true"
action="#{ScriptCallerBean.cb2_action}"/>
</af:form>
</af:document>
</f:view>
managed bean coding
------------------------
import javax.faces.context.FacesContext;
import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;
public void caller(){
ExtendedRenderKitService extRenderKitSrvc = Service.getRenderKitService(FacesContext.getCurrentInstance(),ExtendedRenderKitService.class);
extRenderKitSrvc.addScript(FacesContext.getCurrentInstance(),"window.greeter()");
}
Subscribe to:
Posts (Atom)