Trevor North
Trevor North

Reputation: 2296

How to refresh a select list when another item is changed by a dynamic action?

I am using Apex 4.2 and Oracle XE 11G.

I have a fairly complex page but have created a simplified version and imported it into apex.oracle.com and hope someone can suggest the problem.

Note the design may appear a little strange due to the parts i have removed but i think this should be possible.

The design is using the Mobile theme as it will be executed on either desktop or mobile and i was hoping to only need to build one. Seems there are a few issues with the mobile theme when used on a desktop so might still have to build another GUI later but for now, am just using the mobile one for both desktop and mobile.

I have two elements on the page, an instance type and a version. These will eventually be hidden but are text fields to see what is going on. I also have a region for each instance type containing a drop down list with the version of that instance.

If the instance is defined as the main version, there are certain restrictions on which other versions can be used. These relationships are defined in a table called VERSION_LINKS. The other table holds the versions that the client has access to.

I have created a dynamic action such that changes to the main version will result in updating P1_PRIMARY_VERSION. This field is used in the real application for conditional display of combinations of instances. This update works fine.

The problem is, that field is used in the SQL of the second SELECT LIST (P1_RESTRICTED) and so should then be updated to reflect the valid versions from VERSION_LINKS but instead, the field is just blanked when the P1_VERSION select list is changed.

I have created three ways to resolve this and the application on apex.oracle.com reflects all three.

None of these result in refreshing the list P1_RESTRICTED.

The SQL of P1_RESTRICTED is like this

select vc.version name, vc.version id
   from version_client vc, version_links vl
  where vl.name=:P1_PRIMARY_INSTANCE
    and vl.version=:P1_PRIMARY_VERSION
    and vl.certified_version= vc.version
    and vl.certified_with=vc.name
    and vc.client_id='DMO'
    and vc.name='TWO'
  order by vc.version desc;

and running this with the values as follows gives the right answers

select vc.version name, vc.version id
   from version_client vc, version_links vl
  where vl.name='ONE'
    and vl.version='1.0'
    and vl.certified_version= vc.version
    and vl.certified_with=vc.name
    and vc.client_id='DMO'
    and vc.name='TWO'
  order by vc.version desc;

displays 1.1.6 whilst

select vc.version name, vc.version id
   from version_client vc, version_links vl
  where vl.name='ONE'
    and vl.version='1.1'
    and vl.certified_version= vc.version
    and vl.certified_with=vc.name
    and vc.client_id='DMO'
    and vc.name='TWO'
  order by vc.version desc;

displays 1.1.7

My guess is it's something to do with session state i.e. even though the screen version is showing the P1_PRIMARY_VERSION changing, somehow it is losing the value which is resulting in blanking the second select list.

Any suggestions appreciated as to how to fix this. Thanks in advance Trevor.

Workspace: TESTA
username: tester
password: tester
Application URL: https://apex.oracle.com/pls/apex/f?p=35690:LOGIN_JQM_SMARTPHONE::::::
Developer URL: https://apex.oracle.com/pls/apex

Not this is not the same question as refreshing one apex list from another with ajax. In that case the user is triggering the change and that works fine.

I am trying to have the user make a change in a list which then updates a text field using ajax and another ajax event on this text field should trigger refresh of the second list. There is a reason for doing it this way related to showing one of several regions on the page but using the same single text field to refresh all of them so just doing a straight refresh of one list from another doesnt resolve the issue in this case. That might not be clear from the example on apex.oracle.com because i have tried to reduce it down to the minimum to show the issue. TIA.

Upvotes: 2

Views: 12896

Answers (1)

Tom
Tom

Reputation: 7028

You need to add both P1_PRIMARY_INSTANCE and P1_PRIMARY_VERSION to the list of items to submit under the cascading lov options. These drive your list, and they're only being changed on the page itself. Only submitting P1_PRIMARY_INSTANCE will mean that P1_PRIMARY_VERSION is still NULL when the query is executed, thus returning an empty list.
I changed your page 1 example to reflect this.

Upvotes: 3

Related Questions