Tuesday, November 13, 2007

Create Your Own Meta-HTML Elements

One thing that keeps me excited about PeopleSoft is the flexibility of the PeopleTools platform. As I was working on a a custom Pagelet Transform Type, following the details outlined in Rich's blog post Markdow Text Filtering for PeopleSoft, I realized I was actually creating a custom Meta-HTML element. How cool is that? Not only can I extend the PeopleCode language using Java, I can also extend the Meta tag set. Here is the code:

Function ResolveMetaHTML(&html as string) returns string
Local JavaObject &pattern;
Local JavaObject &matcher;
Local String &node_url;

REM ** Resolve %NodePortalURL(NODENAME) tags;
&pattern = GetJavaClass("java.util.regex.Pattern")

&matcher = &pattern.matcher(
CreateJavaObject("java.lang.String", &html));

While &matcher.find()
&html = Substitute(&html, &matcher.group(), &node_url);

This Meta-HTML element replaces %NodePortalURL(NAMEOFNODE) with the Portal URL defined on the portal tab of the node NAMEOFNODE. This can be used to ensure images, scripts, CSS, links, iframes, etc point to the correct server at runtime.

If you want to create your own Meta-HTML elements, I suggest you place the implementation of those elements inside an Application Class. This custom Application Class would be responsible for accessing its HTML definition using GetHtmlText and replacing all instances of custom Meta-HTML elements with your implementation of those Meta-HTML elements. Rather than call GetHtmlText directly, your PeopleCode would use your custom Application Class.

If this works for Meta-HTML, why not custom Meta-SQL?


Jeromy said...

Thanks Jim for a wonderful Blog! Some excellent information listed here.

Jeromy McMahon

Sasank Vemana said...

Jim - It looks like the link on this post has moved.

I am interested in implementing custom meta-html and wondering if you can give me some pointers.

How is the ResolveMetaHTML function getting executed?

Did you include it in a delivered JavaScript Object?


Jim Marion said...

@Sasank, you have to create your own Display Format, which is an App Class. You then register this app class in the Pagelet Wizard metadata repository. I have an example of creating a data type in my book. Creating a display format is very similar.

Sasank Vemana said...

Great! Thanks Jim.

I will give that a try.