Default language.

Creating data visualization module scenarios


To create data visualization modules, you can use the following scenarios.

 HelloWorld plug-in scenario

This scenario sends back HTML that displays Hello World on the client.

import com.remedy.arsys.plugincontainer.Plugin

   public class HelloWorldPlugin implements Plugin {
       public void init(PluginConfig config) {
       }
       public void processRequest(PluginContext pc) throws IOException, NoPermissionException    {
           HttpServletResponse response = pc.getResponse();
           response.setContentType("text/html;charset=UTF-8");
           PrintWriter writer = response.getWriter();
           writer.println("<html><head><title>Hello World Plugin Example</title></head>");
           writer.println("<body><h1>Hello World</h1></body></html>");
       }
       public String handleEvent(PluginContext pc, String eventType,String eventData) throws IOException, NoPermissionException {
           return "alert(\"Got event data in Midtier as " + eventData + "\");";
       }
       public DefinitionFactory getDefinitionFactory() {
           return null;
       }
       public void cleanup() {}
   }

Event handling code scenario

This scenario shows event handling code added to the generated HTML in the head tag.


   PageService ps = pc.getPageService();
   HttpServletResponse response = pc.getResponse();
   response.setContentType("text/html;charset=UTF-8");
   PrintWriter writer = response.getWriter();
   writer.println("<html><head>");
   writer.println(ps.getEventInfrastructureCode());
   writer.println("<script>function sendMidTierEvent() {");
   writer.println("var result = "+ps.getEventDispatcherName()+
".sendEventToMidTier(\"ClickEvent\",\"Title\");");
   writer.println("eval(result);");
   writer.println("};</script>");
   writer.println("<html><head><title>Hello World Plugin Example</title></head>");
   writer.println("<body><h1 onclick=sendMidTierEvent()>Hello World</h1></body></html>");

Definition factory scenario

This is an scenario of using the definition factory.


   public void processRequest(PluginContext pc) throws IOException, NoPermissionException {
      HttpServletRequest req = pc.getRequest();
      String defName = req.getParameter("name");
      // get our definition object from the definition service.
      MyDefObject def = (MyDefObject) pc.getDefinitionService().getDefinition(name);
       ..... generate the html using def ....
   }
  private DefinitionFactory myDefFactory;
  public void init(PluginConfig config) {
     // create the definition factory and stash it in a member variable for future use.
      myDefFactory=new MyDefObjFactory();
   }
  public DefinitionFactory getDefinitionFactory() {
      // return the stashed definition when the definition service asks for it.
      return myDefFactory;
   }
  private class MyDefObjectFactory implements DefinitionFactory {
      // This method is called by the AR Plugin container if the definition is stored
     //  in the SimpleDefinition field in the Data Visualization Definition form
      public Definition createFromString(PluginContext pc, String defName, String defAsString) throws IOException {
          return new MyDefObject(defName, defAsString);
       }
      // This method is called by the AR Plugin container if the definition is stored
     //  in the ComplexDefinition field in the Data Visualization Definition form
      public Definition createFromStream(PluginContext pc, Strign defName, InputStream defAsStream) throws IOException {
          return new MyDefObject(defName, defAsStream);
       }
   }
  // This class implements CacheableDefinition so that the Definition Service provided by
  // the AR Plugin container caches this object till it sees any modifications in the entry for
  // this definition in the Data Visualization Definition form.
  private class MyDefObject implements CacheableDefinition {
      private MyDefObject(String defName, String defString) {
           ... initialize the def object with the string ...
  
      private MyDefObject(String defName, InputStream is) {
           ... initialize the def object using the stream ...

Using the locale service to format dates scenario

This snippet is an scenario of using the locale service for formatting dates and also formatting the BMC Remedy AR System com.remedy.arsys.Value objects.


   LocaleService ls = pluginContext.getLocaleService();
  // format current date as per current locale and user preferences
   String dateValue = ls.formatDate(new Date());
   ARLocaleService als = (ARLocaleService)ls;
   Value val = getValueFromServer(server, form, fieldId);
   String formattedStr = als.formatValue(val, server, form,view,fieldId);

Using the locale service to get a localized string scenario

This snippet is an scenario of using of the locale service to get a localized string.


   LocaleService ls = pluginContext.getLocaleService();
   String defName=pluginContext.getRequest().getParameter("name");
  int TITLE_ID=100;
   LocalizedStringID localizedTitle = new LocalizedStringID(defName, TITLE_ID);
   LocalizedStringID[] retrieveIDs={localizedTitle};
   String[] localizedStrings = ls.getLocalizedStrings(retrieveIDs);
   String localizedTitle = localizedStrings[0];

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*