prevent 404 if records are empty

Hi,

How do you display a custom page and allow Create Record instead of displaying a 404 whenever the current model is empty?

I need this, because I’m planning to add filtering on an actionView method. Are there any tutorials for beginners in this topic?




public function loadModel($id)

{             

       $model=Flowbook::model()->findByPk($id);

       if($model===null)

		throw new CHttpException(404,'The requested page does not exist.');

       return $model;

}