Pages

Thursday, October 1, 2015

Hello world ucm Custom component

Hello world ucm Custom component :




Purpose :

it is simple component which explains
1.How to create new service
2.How to create new template
3.How to link java class with service
4.How to pass values from class to template

Detailed steps

1. Start ComponentWizard and Add New component “HelloWorld”












































2. After providing the component name , Add the service

3.Add → Service →


4. Provide the service name and other details




















































Name: HELLO_WORLD
Servic Class : Service
Template : ( which will updated after creating the template)
Actions : ( which will updated after creating java class )


5 . Add → Static Table (HTML format )

6. Second page , Merget to column name : ServiceHandlers




7 . Edit resource :
File Name : helloworld_resource.htm Location : Intradoc/custom/HelloWorld/resource
from <td>ServiceHandler</td><td>MyServiceHandler </td><td>MysearchOrder</td>
<td>Service</td><td>Helloworld.MyJavaClass</td><td>MysearchOrder</td>
Line : 16


























8. On the file system , new folder will be created under <>/custom folder
Go to <>/ucm/cs/custom/Helloworld



9. Create folders as
classes/<PackageName>/<Classes>
here
classes/Helloworld/

10. Copy the complied java class . ( Java is menstion at the bottom of the page )

MyJavaClass is the class name
public class MyJavaClass extends ServiceHandler
myJavaMethod is the method name

11. Add the template

Name : helloworld_display
Clas : User
Form Type : Home page
File Name : helloworld_display.htm














































12. Edit helloworld_display.htm using editor : Entire file will at the bottom of the page





<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<$defaultPageTitle="Helloworld"$>
<$include std_html_head_declarations$>
</head>

<$include body_def$>

<$include std_page_begin$>

<$include std_header$>

Helloworld!!


<$include std_page_end$>

</body>
</html>


<$include are required to display the template in normal UCM page .


13 .Go to Build → Build settings → Advanced
Custom Class path : $COMPONENT_DIR/classes ( From drop down) – “ok”
Add → Component Class ( use defailt option) - “ok”



14 . Edit the service as step 4 add the template

15 . Edit the service as step 4 add the java method



































































16. Build → Build

17 . Add DisableAuthorizationTokenCheck=true in config.cfg (to disable to idcToken )


18. Restart the UCM


Verify the component

1. Access IdcService=HELLO_WORLD
it will show























2.In system audit info page add Trace section as “Helloworld”



























3. Verify the server output , after accessing the idc service

>Helloworld/6   10.02 16:48:38.652      IdcServer-52    Paramater1 Passed from service  is null

4. Access like IdcService=HELLO_WORLD&Paramater1=RED
>Helloworld/6   10.02 16:49:46.614      IdcServer-55    Paramater1 Passed from service  is RED



Follow below url to add link : http://wccandlinux.blogspot.in/2015/09/how-to-create-ucm-wcc-custom-component.html



MyJavaClass.java

package Helloworld;

import java.util.*;
import java.io.*;
import intradoc.common.*;
import intradoc.data.*;
import intradoc.server.*;
import intradoc.shared.*;


public class MyJavaClass extends ServiceHandler
{
   
    /**
     * This code will create a html page based on the data in the databinder,
     * and email it to the list of addresses specified by the user.
     */
    public void myJavaMethod() throws DataException, ServiceException
    {
                 String Paramater1;



                       
                    Paramater1 = m_binder.getLocal("Paramater1");

                    traceVerbose( "Paramater1 Passed from service  is " + Paramater1) ;

                 
                       // Accessing standard Java classes
                     String osdetails  = System.getProperty("os.name")+System.getProperty("os.arch")+System.getProperty("os.version") ;
                        // Sending to LocalData to display
                            
                      
                             m_binder.putLocal("osdetails",osdetails);



                 
       
   
    }
   
   



private static void trace(final String message)

              {          // Setting trace section
                           Report.trace("Helloworld", message, null);
              }       


 private static void traceVerbose(final String message)

                  {
               
                if (Report.m_verbose)
                         {
                        trace(message);
                         }
                   }


}




No comments:

Post a Comment