Search code examples
javascriptdom-eventsmouseoveroracle-adfjdeveloper

ClientListener for RichCommandButton


I am required to call a method when mouse hovers onto a RichCommandButton programmatically.

private UIComponent ImageButton(UIComponent parent){
    RichCommandButton img = new RichCommandButton();
    String imagestyle = "width:120pt; height:120.0pt;margin:10.0pt;";
    img.setInlineStyle(imagestyle);
    ClientListenerSet set = img.getClientListeners();
    if (set == null) {
               set = new ClientListenerSet();
            }
    set.addListener("click", "handle");
    img.setClientListeners(set);
    parent.getChildren().add(img);
    AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance();
    adfFacesContext.addPartialTarget(parent);
    return img;  
}

and in my JSPX page,

    <f:facet name="metaContainer">
    <af:resource type="javascript">
        function handle(evt){  
            var source = evt.getSource();
            AdfLogger.LOGGER.logMessage(AdfLogger.SEVERE, 'gangangan');
            evt.cancel();
        }
    </af:resource>
    </f:facet>

It never goes into this function (checked For log message in console on Chrome->Inspect element). Please let me know how I can invoke a method by mouseOver.


Solution

  • Do you use img.setClientComponent(true) in your method? If your JavaScript needs this component then it needs to be present on the client side too.