المكتبة التقنية ←

متى تعمل Dynamic Actions في Oracle APEX؟

English version

A report can be visible while a Dynamic Action is still waiting for the event it was configured to handle. Start debugging by identifying what should trigger the action: the initial page load, a refresh of a specific component, or the completion of an Ajax request.

Separate the server and browser timelines

During rendering, APEX builds the response using server-side processes, conditions, and region queries. In the browser, a Page Load Dynamic Action fires when the DOM is ready. If a task depends on APEX components that delay initialization, consult the documented apexreadyend event. A region refresh is a separate operation. After Refresh applies to components that emit the refresh event.

Example: count visible rows after a report refresh

In a development application, give a Classic Report the Static ID orders_report. Add a static element with ID orders_row_count outside the report. Define the following function in the page’s JavaScript declarations. Adjust the row selector for your report template.

function updateVisibleOrderCount() {
  const report = document.getElementById("orders_report");
  const label = document.getElementById("orders_row_count");
  if (report && label) {
    const count = report.querySelectorAll("tbody tr").length;
    label.textContent = String(count);
  }
}

Call updateVisibleOrderCount(); from a Page Load Dynamic Action for the initial display. Call it again from an After Refresh Dynamic Action targeting the Classic Report for subsequent refreshes. This example counts rendered table rows, including any template rows that match the selector. Use a server-side count if the requirement is the total across all report pages.

Diagnose with two traces

Enable APEX Debug and inspect the server-side render or Ajax request. Then use browser developer tools to check whether the event fired, whether the selector matched, and whether an Ajax action returned an error. For a slow report, measure the region query and network request before changing the event configuration.

Sources: Oracle Dynamic Actions guide and Oracle APEX JavaScript events.

النسخة العربية

ممكن التقرير يظهر على الشاشة بينما الـ Dynamic Action لسه مستنية الحدث اللي اتضبطت عليه. ابدأ التشخيص بتحديد اللحظة المناسبة للتنفيذ: التحميل الأول للصفحة، تحديث مكوّن بعينه، أو اكتمال طلب Ajax.

افصل بين توقيت السيرفر والمتصفح

أثناء تجهيز الصفحة، يبني APEX الاستجابة باستخدام عمليات السيرفر والشروط واستعلامات المناطق. في المتصفح، يحدث Page Load لما يكون الـ DOM جاهز. لو المهمة تعتمد على مكونات APEX اللي بتتأخر في التهيئة، راجع حدث apexreadyend في التوثيق. تحديث منطقة عملية منفصلة. حدث After Refresh ينطبق على المكوّنات اللي بتطلق حدث التحديث.

مثال عملي لعد الصفوف الظاهرة بعد تحديث التقرير

في تطبيق تطوير، أعطِ الـ Classic Report معرّفًا ثابتًا orders_report. أضف عنصرًا ثابتًا بمعرّف orders_row_count خارج التقرير. عرّف الدالة التالية ضمن تعريفات JavaScript في الصفحة. اضبط محدد الصفوف على حسب قالب تقريرك.

function updateVisibleOrderCount() {
  const report = document.getElementById("orders_report");
  const label = document.getElementById("orders_row_count");
  if (report && label) {
    const count = report.querySelectorAll("tbody tr").length;
    label.textContent = String(count);
  }
}

استدعِ updateVisibleOrderCount(); من Dynamic Action بحدث Page Load للعرض الأول. استدعِ الدالة مرة ثانية من Dynamic Action بحدث After Refresh يستهدف الـ Classic Report بعد كل تحديث لاحق. المثال يعد صفوف الجدول المرسومة، بما فيها أي صفوف من القالب تطابق المحدد. لو المطلوب إجمالي الصفوف عبر جميع صفحات التقرير، احسب العدد على السيرفر.

شخّص المشكلة بتتبّع التنفيذ على الجانبين

فعّل APEX Debug وراجع تنفيذ تجهيز الصفحة أو طلب Ajax على السيرفر. بعدها استخدم أدوات المطور في المتصفح للتأكد إن الحدث اتنفّذ، وإن المحدد طابق العنصر المطلوب، وإن طلب Ajax رجع بنجاح. لو التقرير بطيء، قِس زمن استعلام المنطقة وطلب الشبكة قبل تعديل إعداد الحدث.

دليل Dynamic Actions من Oracle ومرجع أحداث JavaScript في Oracle APEX.