Custom Rendering Plugin:
packagecom.ibm.wcmproject;
importjava.io.IOException;
import java.io.Writer;
import java.util.List;
importjava.util.Locale;
import java.util.Map;
importcom.ibm.portal.ListModel;
importcom.ibm.workplace.wcm.api.plugin.rendering.RenderingPlugin;
importcom.ibm.workplace.wcm.api.plugin.rendering.RenderingPluginException;
importcom.ibm.workplace.wcm.api.plugin.rendering.RenderingPluginModel;
public classWCMYouTubePlugin implements RenderingPlugin{
private String PLUGIN_NAME = “video”;
@Override
public booleanisShownInAuthoringUI() {
// TODOAuto-generated method stub
return true;
}
@Override
publicListModel<Locale> getLocales() {
// TODOAuto-generated method stub
return null;
}
@Override
public String getDescription(Locale arg0) {
// TODOAuto-generated method stub
return “Renders a youtube video within WCM Content”;
}
//This method will be use full when accessing the plugin through a tag
@Override
public String getName() {
return PLUGIN_NAME;
}
@Override
public String getTitle(Locale arg0) {
// TODOAuto-generated method stub
return PLUGIN_NAME;
}
//used to render content S
@Override
public booleanrender(RenderingPluginModel pluginModel)
throwsRenderingPluginException {
boolean success = true;
Writer renderWriter = pluginModel.getWriter();
Map<String,List<String>> pluginParams = pluginModel.getPluginParameters();
String width = pluginParams.get(“width”).get(0);
String height = pluginParams.get(“height”).get(0);
String id = pluginParams.get(“video”).get(0);
try {
renderWriter
.append(“<iframe class=”youtube-player” type=”text/html” width=””);
renderWriter.append(width);
renderWriter.append(“” height=””);
renderWriter.append(height);
renderWriter.append(“” src=”http://www.youtube.com/embed/”);
renderWriter.append(id);
renderWriter.append(“” frameborder=”0″></iframe>”);
} catch (IOException e) {
// TODOAuto-generated catch block
e.printStackTrace();
success= false;
}
return success;
}
}
Plugin.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<plugin id=“custom.plugins” name=“Custom Plugin” version=“1.0.0”
provider-name=“Example”>
<extension point=“com.ibm.workplace.wcm.api.RenderingPlugin”
id=“WCMYouTubePlugin”>
<provider class=“com.ibm.wcmproject.WCMYouTubePlugin” />
</extension>
</plugin>
Presentation Template Options
[Plugin:video height=”240″ width=”600″ video=”yqN7nHM1YTA”]