Monday, November 2, 2009

HTML popup using PeopleCode

Thanks to this post I was able to do this as well.

1. Create two work records, one for the web library (e.g. WEBLIB_ACTEST) and one for the buffer field (e.g. ACTEST_WRK). The first record should just have one field (i.e. ISCRIPT1) and the second record should have at least a field to be used as an HTML area and probably a long field (e.g. HTMLAREA).

2. On your page add the HTML area field, e.g. ACTEST_WRK.HTMLAREA, as a field of type HTML Area.

3. Create an HTML object (lets call it ACTEST_1) which will be the actual popup page. For example:

<HTML>
<HEAD>
<TITLE>Popup Window</TITLE>
<BODY>
some text goes here...
</BODY>
</HEAD>

4. Create another HTML object (or alternatively it could be pasted directly into the HTML area as a constant rather than a field) that contains the anchor link (lets call it ACTEST_2):

<a href="#" onclick="window.open('%BIND(:1)','whatevername','width =400,height=400')">Link Name</a>

5. Create an iScript that will allow you to write the html in a new window. An example of the PeopleCode is:

Function Iscript_AcTest
   
   Local string &html;
   
   &html = GetHTMLText(HTML.ACTEST_1);
   %Response.Write(&html);
   
End-Function;

6. Populate the value of the html area on the page. For example on ACTEST_WRK.RowInit:

Local string &subrul, &url;

&suburl = "Iscript_AcTest";
&url = GenerateScriptContentURL(%Portal, %Node, Record.WEBLIB_ACTEST, Field.ISCRIPT1, "FieldFormula", &suburl);
ACTEST_WRK.HTMLAREA.Value = GetHTMLText(HTML.ACTEST_2, &url);

7. Don't forget to assign security for the iScript.

No comments:

Post a Comment