Requirement -Get value of the outputtext in javascript and send it to backing bean in Oracle ADF
Solution – We will use clientListener to call java script function and Serverlistener for calling java function
Below is the code for accomplish this
– page code
<af:outputText value="value outputText" id="ot32" clientComponent="true"
shortDesc="shortDesc">
<af:clientListener type="mouseOver"
method="customJsFunction"/>
<af:serverListener type="mycustomserverEvent" method="#{OutputTextCase11.handleServerEvent}"/>
</af:outputText>
<br></br>
<af:outputText value="Init" shortDesc="shortDesc" id="ot1" clientComponent="true"/>
– find javascript function code
var customJsFunction = function(event)
{
var exceptiondata = event.getSource().findComponent("ot32").getValue();
AdfCustomEvent.queue(event.getSource(),
"mycustomserverEvent",
{param1:exceptiondata},
true);
return true;
}
– method in bean
public void handleServerEvent(ClientEvent ce)
{
String param = (String)ce.getParameters().get("param1");
RichOutputText outputText=(RichOutputText)ce.getComponent().findComponent("ot1");
outputText.setShortDesc(param);
outputText.setValue(param);
AdfFacesContext.getCurrentInstance().addPartialTarget(outputText);
}
happy coding with Vinay in techartifact….