Using RichFaces, you define the dialog as part of the page View definition. It has to be in a separate form from the rest of the page, and any backing bean references in it are going to reflect the values from when the page was loaded, so if you want to do things on the page and have those changes reflected in the dialog,
you should reRender the dialog before making it visible.
The RichFaces ModalPanel isn't something that JavaScript can create "on the fly", because it requires
JSF resources. So it's pre-defined and shown/hidden on command.
For an actual JavaScript-defined dynamic dialog, you'd be talking a lot of delicate work, so a framework like jQuery or dojo would be advisable. RichFaces includes jQuery automatically (it uses it internally), but it's a fairly old version of jQuery.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.