Here is the source code for a complete working example. create a new xpage and in the source view replace the starter code with the code below. save and test in browser.
<?xml version="1.0" encoding="UTF-8"?>
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core">
<xp:button
value="Focus on field and add text"
id="button1">
<xp:eventHandler
event="onclick"
submit="false">
<xp:this.script><![CDATA[var ipt = dojo.byId("#{id:inputText1}");
ipt.focus();
ipt.value = "Paul T. Calhoun";
]]></xp:this.script>
</xp:eventHandler>
</xp:button>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:inputText
id="inputText1"></xp:inputText>
</xp:view>