Controlled drop down based on previous choice

Example1  : i have a drop down on a form  which has 2 values , value 1 and value2. if i choose value 2  i need the next dropdown to show list from entity2 if i choose value 1 i need the next dropdown to show list from entity 1 based on the 1st drop down, the 2nd drop down should show data from different entities.     Example 2 : same situation as above, but this time i have only 1 entity, and both value1 and value2 dropdown data is in this entity. Only difference is that i added a new field to the entity which “contains” the value1 and value2 name in this field against all the records in entity1. so when i make a choice value1 or value2, the dropdown xpath can refer to the association but it wont work as the value is not equal to but contains the value1 or value2. so how to make this work in xpath, the constraint selection wont help as its not equal to. so my basic requirement is that based on 1st drop down choice , i need custom drop down list for the 2nd one.  i tried the xpath association way ( values are not equal but contains) and to try get data from 2 entities based on choice , but neither worked. what other ideas i can try so that i can achieve this…
1 answers

A few things you need to know in general;

- the XPath query or datasource micro/nanoflow set on a reference selector will be executed when the page opens, not when stepping into it

- When refreshing the context object of the enclosing dataview will refresh the reference selectors and re-execute the XPath query or Micro/nanoflow

- Connecting 2 different entities to the same reference selector is not possible in any case

Knowing this you can 

- on change/select of the first value → execute nanoflow which refreshes the context object

- Specify an XPath or Micro/nanoflow which will define the selectable objects

- Add two different reference selectors and set visibility based on the selection in preceding reference selector and thus show only one, depending on the selection.