Workaround for JS Unable to locate control raised by ADF control ID Change

Source: Internet
Author: User
Tags cdata

Original Address:Workaround for JS Unable to locate control raised by ADF control ID Change NICHOLASJSFF defines the control ID that is often changed when it is on the client. For example, one of the IDs in JSFF is "ot1", but when the JSFF is embedded in the Taskflow and displayed in the page in the region, the ID of the control becomes "R1:0:OT1" in the browser. The ADF dynamically modifies the control ID because it is designed to provide reusability while preventing conflicting control IDs. Imagine if there are two jsff in each of the two, whose IDs are ot1, then when these two jsff are introduced to the same page, their ID values will conflict. To solve this problem, the ADF adds the information for the container in which the control is located in the resulting ID. The R1 in "R1:0:ot1" is the name of the region where JSFF Taskflow is located. Because of the change of ID, the client JS script is difficult to locate the control. The solution is actually very simple, that is to find a constant ID, through this ID to locate the control. A simple workaround is to define a helper CSS class for the control to ensure that the class name is not duplicated. Examples are as follows: <! [cdata[
<af:resource type= "javascript" source= "/js/jquery.js"/>
<af:resource type= "JavaScript" >
function Invokejavamethod () {
    var clientId = $ (". Serverlistener") [0].id;
var com = AdfPage.PAGE.findComponentByAbsoluteLocator (clientId);
Adfcustomevent.queue (COM, "MyEvent", {userName: ' Nicholas '}, True);
}
</af:resource>
<a onclick= "Invokejavamethod (); >click me</a>
<af:outputtext value= "" id= "Ot1" visible= "false" styleclass= " Serverlistener">
<af:serverlistener type= "MyEvent" method= "#{pageflowscope.mybean.docustomevent}"/>
</af:outputText>
A potential problem with]]> is that if the same taskflow is referenced multiple times on the same page, there will be multiple elements that have the CSS on which the positioning depends. There are two ways to resolve this: 1. Define an input parameter for Taskflow as the value of the CSS. Conflicts can be avoided if the call is to enter a different value for the Taskflow. 2. The ID value can be obtained using the relative position of the element. Because regardless of how taskflow is nested and reused, the relative position of the page element is constant. <! [Cdata[<af:resource type= "JavaScript" source= "/js/jquery.js"/>
<af:resource type= "JavaScript" >
function Invokejavamethod (ID) {
var clientId = id.id;
var com = AdfPage.PAGE.findComponentByAbsoluteLocator (clientId);
Adfcustomevent.queue (COM, "MyEvent", {userName:id.innerText}, true);
}
</af:resource>
<a onclick= "Invokejavamethod ( this.nextsibling); "Href=" # ">click me</a>
<af:outputtext value= "#{pageflowscope.taskname}" id= "Ot1" visible= "false" styleclass= "Serverlistener" >
<af:serverlistener type= "MyEvent" method= "#{pageflowscope.mybean.docustomevent}"/>
</af:outputText>]]>

Workaround for JS Unable to locate control raised by ADF control ID Change

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.