CPD Results

The following document contains the results of PMD's CPD 4.2.2.

Duplications

File Line
org/springbyexample/web/servlet/view/tiles2/TilesAjaxUrlBasedViewResolver.java 30
org/springbyexample/web/servlet/view/tiles2/TilesUrlBasedViewResolver.java 30
public class TilesUrlBasedViewResolver extends UrlBasedViewResolver {

	private String tilesDefinitionName = null;
	private String tilesBodyAttributeName = null;
	private String tilesDefinitionDelimiter = null;

	/**
	 * Main template name.
	 */
	public void setTilesDefinitionName(String tilesDefinitionName) {
		this.tilesDefinitionName = tilesDefinitionName;
	}

	/**
	 * Tiles body attribute name. 
	 */
	public void setTilesBodyAttributeName(String tilesBodyAttributeName) {
		this.tilesBodyAttributeName = tilesBodyAttributeName;
	}

	/**
	 * Sets Tiles definition delimiter.  
	 */
	public void setTilesDefinitionDelimiter(String tilesDefinitionDelimiter) {
		this.tilesDefinitionDelimiter = tilesDefinitionDelimiter;
	}

	/**
	 * Does everything the <code>UrlBasedViewResolver</code> does and 
	 * also sets some Tiles specific values on the view.
	 * 
	 * @param viewName the name of the view to build
	 * @return the View instance
	 * @throws Exception if the view couldn't be resolved
	 * @see #loadView(String, java.util.Locale)
	 */
	protected AbstractUrlBasedView buildView(String viewName) throws Exception {
		AbstractUrlBasedView view = super.buildView(viewName);
		
		// if DynamicTilesView, set tiles specific values
		if (view instanceof DynamicTilesView) {
			DynamicTilesView dtv = (DynamicTilesView)view;
			
			if (StringUtils.hasLength(tilesDefinitionName)) {
				dtv.setTilesDefinitionName(tilesDefinitionName);
			}
			
			if (StringUtils.hasLength(tilesBodyAttributeName)) {
				dtv.setTilesBodyAttributeName(tilesBodyAttributeName);
			}

			if (tilesDefinitionDelimiter != null) {
				dtv.setTilesDefinitionDelimiter(tilesDefinitionDelimiter);
			}
		}
		
		return view;
	}
	
}