This Technical Note contains an example that can be used to append a prefix to subscription names, when creating or editing subscriptions in Strategy Web.
Using the Web Customization Editor to create this customization:
Strategy SDK provides a Web Customization Editor that can be used to create a customization plug-in. The following steps guide users in creating the plug-in for adding the user history list to the Desktop page:
Sample add-on code:
/**
* Strategy SDK Sample
*
* Copyright � 2011 Strategy Incorporated. All Rights Reserved.
*
* Strategy MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
* SUITABILITY OF THIS SAMPLE CODE, EITHER EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE, OR NON-IN *
*
*/
import com.Strategy.web.app.addons.AbstractAppAddOn;
import com.Strategy.web.app.beans.PageComponent;
import com.Strategy.web.beans.RequestKeys;
import com.Strategy.web.beans.SubscriptionBean;
import com.Strategy.web.beans.WebBeanException;
import com.Strategy.web.beans.WebComponent;
import com.Strategy.web.objects.WebObjectsException;
public class DynamicSubNames extends AbstractAppAddOn {
public String getAddOnDescription() {
return "";
}
public String getCustomPrefix(){
return "CUSTOM PREFIX";
}
public void preCollectData(PageComponent page) {
System.out.println("preCollectData");
SubscriptionBean sb;
try {
sb = getSubscriptionBean(page);
// Check prefix hasn't already been applied
if(!sb.getSubscription().getName().contains(getCustomPrefix())){
// Set custom prefix
sb.getSubscription().setName(getCustomPrefix()+sb.getSubscription().getName());
sb.getSubscription().save();
}
} catch (WebBeanException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (WebObjectsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return;
}
// Custom method to retrieve the subscriptiion bean from WebComponent
private SubscriptionBean getSubscriptionBean(WebComponent wc) {
SubscriptionBean result = null;
if (wc instanceof SubscriptionBean) {
System.out.println("wc.getname :"+wc.getName());
result = (SubscriptionBean) wc;
}
else
{
for (int i = 0; i < wc.getChildCount(); i++) {
result = getSubscriptionBean(wc.getChild(i));
if (result != null) break;
}
}
return result;
}
}