Forum Stats

  • 3,817,327 Users
  • 2,259,314 Discussions
  • 7,893,750 Comments

Discussions

Can StaticContent Regions be changed via Dynamic Actions in v20.1?

Amba
Amba Member Posts: 36 Green Ribbon
edited Jul 10, 2020 10:51AM in APEX Discussions

Hello I would appreciate your help with this one..

I am trying to dynamically change the image and text of a page, using Dynamic Actions. While I can successfully set up the page to display image and text using initial (SQL based) values, they do not update on Dynamic Events or via PL/SQL's SELECT INTO :ITEM statements.

My use case is that when user triggers a change in the DEPTNO_USR_INPUT item (I am using the Oracle standard EMP table), a Dynamic Event auto populates the item to its right: EMPNP_USR_AUTOPOPULATED -- with the EMPNO of the  longest serving employee in that department..The submit button then does the DML form processing and retrieves the employee details. All that part is working. (which is amazingly low-code ajax development by this inexperienced developer, for sure)

--

=> now, the same Dynamic Event is also setup to change the value of an image and text in the StaticContent region (called StaticImageRegion) further down the page. This does not work... I have even tried to do the same thing via another FormRegion, which also doesn't work.

Expected behaviour: The image below would change to a different one (ID=2) and text will change to "more text". [I have hardcoded SQL by ID just to show items.  In a real application they will be driven by :bind variables etc]

I am definitely missing quite a few concepts - even though I can get Ajax type forms to work in Apex 20.1.. what do you suggest? Screenshots below:

update: I have learnt that I cannot use Form Regions to 'refresh' under any circumstances (and a submit/DML does not suit this purpose). Therefore a Classic Report region is better suited. In any case, so far it looks like StaticContent Regions cannot be updated once they have been loaded onto the page for the first time.. (unless someone knows if this is incorrect - it would certainly make this  a lot easier..)

Part 1/2 of the page:

Screen Shot 2020-07-10 at 7.50.53 PM.png

... Part 2/2 of the page continues below

Screen Shot 2020-07-10 at 7.50.28 PM.png

Here is the PageDesigner View: the DynamicAction 'evDeptChange' triggers multiple events (I have used Alert() to verify that page execution reaches all of them correctly. While the first SetValue works like a charm.. the others do not. [ Execute PL/SQL code is set to work on the StaticRegion whilst Refresh is set to refresh the Image form..none of these work] btw, I store all images in a table called GALLERY in which column IMAGE is a BLOB.

pastedImage_4.png

.... and below: I have created a FormRegion called ImageFormRegion just to try a different approach (which does not work).

pastedImage_3.png

Answers

  • Amba
    Amba Member Posts: 36 Green Ribbon
    edited Jul 10, 2020 6:40AM
    update: please ignore this post (perhaps, I should delete it). I now understand that FormRegions need DML setup to work dynamically and for this use case, it is not ideal. (am attempting to use ClassicReport for this - even though I feel that a simple assignment into a StaticContentRegion might have been the most elegant solution)

    Amazingly (and puzzling) the ImageForm Region is now working! .. and this is only because I changed the ImageFormRegion's P10_IMAGE item --> Settings -> BLOB Column returned by SQL query into

    "select image from gallery where id = 2"

    I wonder why this works and the Setting: " BLOB Column specified in  Item Source " does not work, when in fact: the Item Source was pointing the correct Report Region and generating the column values like so:

    pastedImage_1.png

  • Amba
    Amba Member Posts: 36 Green Ribbon
    edited Jul 10, 2020 5:44AM

    (much) more puzzling behaviour:

    when I change the sql statement from the hardcoded "select image from gallery where id =2" to "select image from gallery where id := :P10_ID" - which should be a better dynamic version - and because correspondingly  I have PL/SQL code ( :P10_ID := 2;) in the form initialization process (form load) --- I get a broken image in the ImageForm Region...

    pastedImage_1.png

  • Veerendra Patil
    Veerendra Patil Member Posts: 577 Gold Badge
    edited Jul 10, 2020 6:52AM

    Hi Amba,

    Please check fac586's answer on

    Please let me know if this what you are looking for?

    Thanks,

    Veerendra.

  • Amba
    Amba Member Posts: 36 Green Ribbon
    edited Jul 10, 2020 8:43AM

    Hi Veerendra

    Thanks a lot for your response and suggestion. I have had a look at this and here are my thoughts

    @fac586 's answer pertains to a composite PK issue which is not true in my case. Mine is a very simple usecase with a single, simple PK autogenerated via trigger...

    pastedImage_0.png

    Also there appears to be cross-page rendering questions there. In my case, it is a simple matter of retrieving the image via a  SELECT _ WHERE ID := _ statement and presenting it to (a) StaticContent (b) Form  (c) ClassicReport regions. I am trying out all three at the same time.  I think I have worked out that in my case the dynamic reference  ID := PX_ID is not working is because Forms require DML logic to work, they will be fine "hardcoded". So, okay its probably the wrong (design) approach in the first place..

    What's interesting is that APEX does not (appear to) accept any reassignments of its items within StaticContent regions at runtime (via PL/SQL for instance)  Do you know if that is true?

    Now I am trying to use ClassicReport region to do the same thing - which is obviously not the preferred option because of the intense overhead of having to refresh the whole region for an image to display..

    [Also, I tried to use your vpagmws/testuser workspace but I think its no longer operational.. ]

    thanks again.

  • fac586
    fac586 Senior Technical Architect Member Posts: 20,838 Red Diamond
    edited Jul 10, 2020 9:10AM
    Amba wrote:Thanks a lot for your response and suggestion. I have had a look at this and here are my thoughtsfac586 's answer pertains to a composite PK issue which is not true in my case. Mine is a very simple usecase with a single, simple PK autogenerated via trigger...

    No, the answer marked as correct by the OP pertains to a composite PK issue. The actual answer is given in an earlier post:

    The BLOB Column returned by SQL statement item setting can only be used to specify an initial image. Dynamic changes of the displayed image at runtime are achieved by changing the URL referenced in the image src property. The URLs involved are dependent on where the images are stored and how they are uploaded.

    This is a common problem on these forums. Users mark the post that finally resolves their problem as correct, and this is often a trivial point rather than a substantive description of the solution. Sometimes users mark a wrong answer as correct, or a better solution is added later. Always read linked threads in full.

    Amba
  • Amba
    Amba Member Posts: 36 Green Ribbon
    edited Jul 10, 2020 10:02AM

    thanks a lot for the clarification @fac586 - I now understand that the actual img src  is contructed once by APEX, like so in my case:

    <img src="apex_util.get_blob?s=701732350360135&amp;a=26914&amp;c=27811320006491015146&amp;p=10&amp;k1=%33&amp;k2=&amp;ck=uPztAJU6fOVwZaDQLL62I2NNLt68cM5Uw-7jRrUXqtd-n5chDrv8fcjh87rxq46hylx8grY6g5_hhG8LYSs7Pw&amp;rt=CR">

    In your original response you have suggested the use of apex_util.get_blob.get_blob_file_src function.

    Now, the official documentation states the this requires the "Name of valid application page ITEM that with type FILE that contains the source type of DB column."

    In my case, I am retrieving an IMAGE (type BLOB) from a database table (GALLERY), not a filesource. So I am stuggling with the language.. ' that with type FILE that contains the source type of DB column'

    I'll go over this a few times again - along with your walkthrough in the previous thread.. thanks again.

  • Amba
    Amba Member Posts: 36 Green Ribbon
    edited Jul 10, 2020 10:22AM

    @fac586 you wrote, earlier:

    ...,...,...<snip>....

    Event: Change

    Selection Type: Item(s)

    Item(s): P2_USER_ID

    True Actions

    Action: Set Value

    Set Type: PL/SQL Expression

    PL/SQL Expression: apex_util.get_blob_file_src('PX_FILE', :p2_user_id, null, 'inline') // Replace "PX_FILE" with the name of the file browse item originally used to upload these images.

    ......<snip>.....

    In my case, I inserted the BLOB directly into the database via SQL (via an autoREST/PUT operation).. so does that mean this function does not apply?

    what is also interesting is that the generated image src references the apex_util.get_blob function ~ there appears to be no documentation that I can locate on it. There's only the  get_blob_file_src function.. Or, perhaps I am going off on a tangent here.

  • fac586
    fac586 Senior Technical Architect Member Posts: 20,838 Red Diamond
    edited Jul 10, 2020 10:47AM
    Amba wrote:In my case, I inserted the BLOB directly into the database via SQL (via an autoREST/PUT operation).. so does that mean this function does not apply?

    It doesn't in that you aren't building on existing components. However, the page item parameter is simply a shortcut used to get information about the BLOB from the metadata associated with the file upload item and process used to load the images. If these components don't already exist because the images are not loaded in this way, then a workaround is to add the file upload item and form initialization process that would be used in uploading an image to the table to a page, set Never conditions on them so they're not displayed or executed, and reference the item in the apex_util.get_blob_file_src calls.

    what is also interesting is that the generated image src references the apex_util.get_blob function ~ there appears to be no documentation that I can locate on it. There's only the get_blob_file_src function.. Or, perhaps I am going off on a tangent here.

    Perhaps. There are other ways to dynamically expose images:

    1. A custom On-Demand Process
    2. A RESTful web service

    I like the on-demand process method because it is a standard application component with built-in support for the APEX security model. You might prefer a REST service because that is how the existing images are loaded.

    Amba
  • Amba
    Amba Member Posts: 36 Green Ribbon
    edited Jul 10, 2020 10:51AM

    Ok So I have managed to dynamically update the image using a ClassicReportRegion, --- by adding an additional 'Refresh' event (true) to the PX_ID item (key) in the region. How it works is a mystery to me (especially the get_blob() function part..

    > and it appears as if other approaches will only fetch image src once, which probably makes StaticContent not the correct approach in this case..

    pastedImage_0.png