All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.ydn.wicket.wicketconsole.ScriptResultRendererManager Maven / Gradle / Ivy

There is a newer version: 1.3
Show newest version
package ru.ydn.wicket.wicketconsole;

import java.util.LinkedList;

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

public class ScriptResultRendererManager implements IScriptResultRenderer{
	
	public static final ScriptResultRendererManager INSTANCE = new ScriptResultRendererManager();
	
	private LinkedList renderers = new LinkedList();
	
	public ScriptResultRendererManager() {
		registerRenderer(new DefaultScriptResultRenderer());
	}
	
	public void registerRenderer(IScriptResultRenderer renderer) {
		renderers.push(renderer);
	}

	@Override
	public Component render(String id, IModel data) {
		for(IScriptResultRenderer renderer:renderers) {
			Component ret = renderer.render(id, data);
			if(ret!=null) return ret;
		}
		throw new WicketRuntimeException("Object "+data.getObject()+" can't be rendered");
	}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy