The trick is that the category widget looks up the information from the database. If you are mapping a new item values is empty otherwise it has
[list $object_id $container_id] (well, actually that is deprecated -- they are supposed to be passed as attributes category_application_id and category_object_id now, but project manager uses the old form).
Look at template::widget::category for the gory details.
You could also look at lars-blogger for a somewhat higher level interface which handles creating multiple form elements if you have multiple trees mapped.