JavaScript and Java communication

I have a UI library that can now build a UI from an XML file. Now, I want to give buttons actions defined in a JavaScript-like format so I can have a script like this:

function logOut() {
  getUser().logOut();
  setScreen(0);
}

and in my XML files have this:

<click action="logOut()" />

Does anybody have any guidance so I can parse the JavaScript at runtime and use it with my XML in order to replicate an effect like HTML-JavaScript communication?

CopyableCougar4