Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package net.ftlines.wicketsource;
  
  
  
Holds information about where a component was created. Pairs with a AttributeModifyingComponentVisitor to record the source information in an html attribute for inspection and (eventually) click-through. The new MarkupException in the constructor here is an alternative to component.getMetaData(Component.CONSTRUCTED_AT_KEY) which is package-private and thus internal to wicket. If wicket eventually exposes the markup exception from creation time, we can use that directly instead of keeping our own separate Throwable.

Author(s):
Jenny Brown
 
 public class InstantiationLocation implements Serializable {
 	private static final long serialVersionUID = 1L;
 
When a component is instantiated, record its source location as part of its metadata.

Parameters:
component being instantiated
Throws:
AttributeModifyingInstantiationListener.UnsupportedComponentException
 
 	public InstantiationLocation(Component component
 	{
 		 = WicketSourceFilter.findCreationSource(new MarkupException("constructed"), component);
 		if ( == null) { 
 			throw new UnsupportedComponentException(component.getId());
 		}
 	}

What kind of wicket component is this (Label, BookmarkableLink, etc) - convenience lookup.

Parameters:
component to identify
Returns:
string with the class name of the component
 
 	public String getComponentType(Component component)
 	{
 		return WicketSourceFilter.getClassName(component);
 	}

Returns:
Gets a string from a stack trace element indicating the package that the class came from or empty for default package
 
 	{
 		if (.getClassName().indexOf('.') == -1) { // default package
 			return "";
 		} else {
 		}
 	}

Returns:
Gets a string from a stack trace element indicating the class that the component came from
 
 	private String getClassLocation()
 	{
 		if (.getClassName().indexOf('.') == -1) { // default package
 		} else {
 		}
 	}

Returns:
Gets the filename from a stack trace element
 
 	private String getFilename()
 	{
 	}

Returns:
Gets the line number of the source location from a stack trace element
 
 	private Integer getLineNumber()
 	{
 	}

Produces the value for the html attribute describing the location in Java source of this component. Result is of the form net.simsa.packagename:ClassName.java:35 (package:file:line).

Parameters:
component to search for
Returns:
String indicating package : filename.java : lineNumber
	{
		return getPackageLocation() + ":" + getFilename() + ":"getLineNumber();
	}
	public String toString()
	{
		return "InstantiationLocation: packageLocation=" + getPackageLocation() + ", classLocation="
getClassLocation() + ", lineNumber=" + getLineNumber();
	}
New to GrepCode? Check out our FAQ X