Skip to Content

I have seen many questions in forums, where people want to read files stored in KM and display at various places like Masthead, Logon Page etc. I have tried to develop a generic framework which can be used to develop more specific solutions. This discussion has been divided in two parts, in the first part we will be building the framework and in the second part we will discuss about the various use case, where this solution can be implemented. I will also share some real life examples where I have implemented this approach successfully.

I have tried to divide the solution in three parts; each of them can be reused independently.

1. The Tag library to read files in KM

2. The iView which displays the content

3. The actual content which is stored in KM

Tag Library

The tag library can be used to read the files from the KM. You need to specify the file path, whether anonymous access is required and do you want localization. In case you set localizable as true, it looks for filename_xx where xx is the locale in lowercase.

1. Create a Portal Project in my case it’s com.cts.km.generic.

2. Add the following  jar files to the Project Build Path:

api.jar, bc.rf.framework_api.jar, bc.util.public_api.jar, com.sap.portal.usermanagementapi.jar, com.sap.security.api.ep5.jar, servlet.jar

3. In src.api create a class com.cts.km.taglib.KMTag which extends TagSupport

4. Copy and paste the below code (Adjust if you are using a different package or class name)

5. The code is self explanatory, and I have given comments where I thought it’s necessary. Rebuild the project and Organize the imports

6. Create a file km.tld in dist->PORTAL-INF->taglib folder.

7. Copy and paste the below code

8. Adjust the portalapp.xml so that it looks like

9. Rebuild and deploy on the Portal Server.

Message Board

This is a sample implementation of the Taglib, we developed in the last section.

1. Create a JSPDynpage Project. In my case the Project name is  com.cts.messageboard, The DynPage class is com.cts.msg.MessageBoard and the JSP name is MessageBoard.jsp

2. You can leave the JSP Dynpage class as it is.

3. Copy and paste the following code for the JSP

4. Adjust the portalapp.xml so that it looks like

The JSP first declares the use of the CTSKMTagLibrary. From the component profile it reads the File Path which appears as iView property and can be supplied by Portal Content Administrator. In my case all my files are getting stored inside documents/cts so I am passing the parameter relative to documents/cts. Also note the use of localization and anonymous access. For anonymous access to work The KM permissions should be set accordingly. Also don’t pass the filename_xx (Where xx is locale) in the parameter. Just pass filename and the code will take care of the xx part. However you need to have two files filename and filename_xx in the specified path.

5. Rebuild and Deploy the Project.

This concludes the first part of the discussion. In the second part we will see some real life examples and of course some more codes :-).

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply