IBM WCM 8.5 Rendering Plugin Example to render Youtube Video in a web content

Create a Dynamic Web project

Create the following java class which implements RenderingPlugin interface
Class:

package com.ibm.plugins;

import java.io.IOException;
import java.io.Writer;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import com.ibm.portal.ListModel;
import com.ibm.workplace.wcm.api.plugin.rendering.RenderingPlugin;
import com.ibm.workplace.wcm.api.plugin.rendering.RenderingPluginException;
import com.ibm.workplace.wcm.api.plugin.rendering.RenderingPluginModel;

public class YoutubePlugin implements RenderingPlugin {

private String PLUGIN_NAME = "video";

@Override
public boolean isShownInAuthoringUI() {
return true;
}

@Override
public String getDescription(Locale arg0) {
return "Renders a youtube within WCM content";
}

@Override
public ListModel getLocales() {
return null;
}

@Override
public String getTitle(Locale arg0) {
return PLUGIN_NAME;
}

@Override
public String getName() {
return PLUGIN_NAME;
}

@Override
public boolean render(RenderingPluginModel p_model)
throws RenderingPluginException {
boolean success = true;
Writer renderWriter = p_model.getWriter();
Map> pluginParams = p_model.getPluginParameters();

// Get Dimentions
String width = pluginParams.get("width").get(0);
String height = pluginParams.get("height").get(0);

// Get video ID
String id = pluginParams.get("video").get(0);

try {
renderWriter.append("");
} catch (IOException ioe) {
ioe.printStackTrace();
success = false;
}
return success;
}

}

Plugin.xml:






Install the Application on WAS console and start the applicatrion

Create any of component insert tag

of in the plgin component list you video rendering plugin available insert into component and supply width, height, id of video

[Plugin:video width=”320″ height=”240″ video=”r5SuUY7dF1w”]

Leave a Reply

Your email address will not be published. Required fields are marked *

Enable Notifications OK No thanks