You should simply modify your action to handle username, e.g. :
public function actionView($id=null, $username=null)
{
if (isset($id))
$model = User::model()->findByPk($id);
else if isset($username))
$model = User::model()->findByAttributes(array('username'=>$username));
if ($model===null)
throw new CHttpException(404,'The requested page does not exist.');
$this->render('view',array(
'model'=>$model,
));
}
And make sure :
- username is unique,
- you have the corresponding url rule in your config.