/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.wicket.behavior;

import org.apache.wicket.Component;
import org.apache.wicket.WicketRuntimeException;

/**
 * Thrown when a behavior with an invalid id is requested
 * 
 * @author ivaynberg (Igor Vaynberg)
 */
public class InvalidBehaviorIdException extends WicketRuntimeException
{
	private static final long serialVersionUID = 1L;

	private final Component component;
	private final int behaviorId;

	/**
	 * Constructor
	 * 
	 * @param component
	 * @param behaviorId
	 */
	public InvalidBehaviorIdException(Component component, int behaviorId)
	{
		super(
			"Cannot find behavior with id: " +
				behaviorId +
				" on component: " +
				component +
				". Perhaps the behavior did not properly implement getStatelessHint() and returned 'true' " +
				"to indicate that it is stateless instead of returning 'false' to indicate that it is stateful.");
		this.component = component;
		this.behaviorId = behaviorId;
	}

	/**
	 * @return component which was thought to contain the behavior
	 */
	public Component getComponent()
	{
		return component;
	}

	/**
	 * @return behavior id
	 */
	public int getBehaviorId()
	{
		return behaviorId;
	}
}

@@ -1421,16 +1421,30 @@
 er(%0D%0A%09%09%09
+String.format(
 %22Cannot 
@@ -1468,71 +1468,47 @@
 h id
-: %22 +%0D%0A%09%09%09%09behaviorId +%0D%0A%09%09%09%09%22 on component: %22 +%0D%0A%09%09%09%09component
+ '%25d' on component '%25s' in page '%25s'. %22
  +%0D%0A
@@ -1512,18 +1512,16 @@
 +%0D%0A%09%09%09%09%22
-. 
 Perhaps 
@@ -1704,16 +1704,102 @@
 ateful.%22
+,%0D%0A%09%09%09%09%09behaviorId,%0D%0A%09%09%09%09%09component.getClassRelativePath(),%0D%0A%09%09%09%09%09component.getPage())
 );%0D%0A%09%09th

Improve exception message to say the full path of a component in a page and the name of the page it is added to.