Delayed reflection of service response on Modal Dialog

Here is the context.
I have portlet which is populating a table. There is async command link at the first column of every row.
User can click on the async command link which invoke a service and toggle a modal dialog. This service has few input which can be provided from the selected row of the table and output as a list.

Problem
When User clicks on async command link service is getting invoked and modal dialog pops up. But response from service is not reflecting when modal dialog pops up for the first time. Once i close the modal dialog and again click on the async command link then service response is showing on the modal dialog.

I am attaching a sample POC of the problem. please check it. If we can show the list of names when modal dialog appears for the first time. Then we can solve the actual problem also.

TestModalDialog.zip (16.7 KB)

Hi All

Luckily i got he solution and its working fine.

I am attaching the working code.
TestModalDialog1.zip (17.1 KB)