Hello Mohan,
Your solution seems to work fine. But if you want to give it a try....
You could try solving it using different specializations of a FileDocument entity. A specialization for each type you want to treat differently.
Then you could use from the datagrid the functionality to link different "edit" pages for different specializations.