The preview button should only be available if the cohort definition is saved.  So, only show this button if the definition.id != null.  I am assuming this will solve your NullPointerException issues.