Copying Custom Controls

This tip is pretty simple, and it might be common knowledge to most people, but I stumbled onto it pretty much by accident.

Copying a custom control from one XPage to another is fairly common, but when you do so and go to build your new page, you get the message:

The prefix “xc” for element “xc:ccTest” is not bound.

error_message

Previously, I never really bothered to look into this message any further.  I took the easy way out and simply dragged a new copy of the custom control onto the XPage, copied any custom properties (if any), and went on my way.  However, this can get annoying REAL fast if you have a lot of custom controls that need to be copied.

Luckily, there is a ridiculously easy way to quickly get rid of the above message.

When you create a new Xpage, the standard markup looks like this:

<?xml version="1.0" encoding="UTF-8"?> 
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"> </xp:view>

Look what happens as soon as you drag a custom control on to your XPage:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
	xmlns:xc="http://www.ibm.com/xsp/custom">
	<xc:ccTest></xc:ccTest>
</xp:view>

Adding the bolded line above to the xp:view tag of your page will allow you to copy custom controls to your XPage without frustration.  At the end of the day is it really a big time saver?  No.  But at least you have a better understanding of the error message.