79506485

Date: 2025-03-13 12:43:34
Score: 1
Natty:
Report link

You can also run a javascript function inside your ADF java bean : https://cedricleruth.com/how-to-execute-client-javascript-in-an-adf-java-bean-action/

/*** In YOURJSF.jsf button, or other component that need to execute a javascript on action, add : ****/
<af:commandButton text="ClickMe" id="cb1" actionListener="#{YOURSCOPE.YOURJAVABEAN.clickToExecuteJavascriptAction}"/>
 /*** In YOURJAVABEAN.java class add : ***/
 public void clickToExecuteJavascriptAction(ActionEvent actionEvent) {
  this.executeClientJavascript("console.log('You just clicked : " + actionEvent.getSource() + " ')");
  //Note: if you use a java string value in this function you should escape it to avoid breaking the javascript.
  //Like this : stringValue.replaceAll("[^\\p{L}\\p{Z}]", " ")
 }

//You should put this function in a util java class if you want to use it in multiple bean
public static void executeClientJavascript(String script) {
 FacesContext facesContext = FacesContext.getCurrentInstance();
 ExtendedRenderKitService service = Service.getRenderKitService(facesContext, ExtendedRenderKitService.class);
 service.addScript(facesContext, script);
}
Reasons:
  • Probably link only (1):
  • Contains signature (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Cedric