Need some more information from your side....
As per my understanding create popup with all the components.Initial step hide the popup using rendered attribute.
After getting the result from the Query from backing bean set some variable to true,
flagResult = "Success"
Here already you have rendered attribute as failure while loading first time.Once you get the result from the query backing bean you are changing the value to Success.
Now the popup will display the result(nothing but you list item or pojo from query).
Similar way you display for null values also.If the query returning empty.