Search code examples
javascriptoracle-adf

get the return value from js function in java back bean in oracle adf


I want to use the return value of a JS function from java back bean ... I know how to just call the method by this code

public void callJSSnap(ActionEvent actionEvent) {

FacesContext context = FacesContext.getCurrentInstance();
ExtendedRenderKitService erks =
Service.getService(context.getRenderKit(),
       ExtendedRenderKitService.class);

erks.addScript(context, "snap();");


    // Add event code here...
}

its just a void function ... what if I had a javascript function that returns a value and I want to use it in oracle add Java Back bean


Solution

  • There is no direct assess to javascript from the server.

    You have to queue a custom event inside the JS function which passes the result back to the server. This is the typical at:clientListener at:serverListener situation. Check the doc at https://docs.oracle.com/cd/E28280_01/apirefs.1111/e12419/tagdoc/af_serverListener.html