I need help with PL/SQL Dynamic Content Region.
Based on selection in page item (on item change event) dynamic content region should be refreshed to show all images based on selected value images in page item. PL/SQL generates html slider:
declare
is_first boolean := true;
begin
sys.htp.p('<html>');
sys.htp.p('<head>');
sys.htp.p('<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">');
sys.htp.p('<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>');
sys.htp.p('<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>');
sys.htp.p('<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>');
sys.htp.p('</head>');
sys.htp.p('<body>');
sys.htp.p(:P23_CAR_ID);
sys.htp.p('<div id="simple_carousel" class="carousel slide" data-ride="carousel">');
sys.htp.p('<div class="carousel-inner">');
for a in (select car_image_id
from car_images
where car_id = :P23_SELECT) loop
if is_first then
sys.htp.p('<div class="carousel-item active">');
is_first := false;
else
sys.htp.p('<div class="carousel-item">');
end if;
sys.htp.p('<img src="https://apex.oracle.com/pls/apex/appname/images/cars/' || (a.car_image_id) || '" class="d-block w-100" alt="Image ' || apex_escape.html(a.car_image_id) || '">');
sys.htp.p('</div>');
end loop;
sys.htp.p('</div>');
sys.htp.p('<a class="carousel-control-prev" href="#simple_carousel" role="button" data-slide="prev">');
sys.htp.p('<span class="carousel-control-prev-icon" aria-hidden="true"></span>');
sys.htp.p('<span class="sr-only">Previous</span>');
sys.htp.p('</a>');
sys.htp.p('<a class="carousel-control-next" href="#simple_carousel" role="button" data-slide="next">');
sys.htp.p('<span class="carousel-control-next-icon" aria-hidden="true"></span>');
sys.htp.p('<span class="sr-only">Next</span>');
sys.htp.p('</a>');
sys.htp.p('</div>');
sys.htp.p('</body>');
sys.htp.p('</html>');
end;
Page loads without errors, after change of item value (which is LOV), following error, that has no much sense appears:
Error: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
If I set page item session state storage to “Session (Persistent)”, after page reload, it shows slider just fine, with all images.
Also, If I hardcode car_id in sql, it shows slider in initial page load as it should, therefore my conclusion is that something is not synchronized correctly.
Dynamic action configuration and order:
On item change (P23_Select), True action: Refresh PLSQL Dynamic Content Region.
fire on initialization is disabled.
I tried to add new page item, that will capture if first item change is handled properly, so I set value based on first item change, and it works as expected, second item get value after change of first one correctly, but for some reason, it does not work properly for the region.
I am not sure if makes sense to try to create a function in DB and just call it in region.
Any help would be much appreciated.
Kind Regards,
Strahinja
Strahinja is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.