Tuesday, February 16, 2010

XMLP PeopleCode: unzip

/* Unzip the zip file contents using the Peoplesoft XMLPUtil java class.*/
&joUtil = CreateJavaObject("com.peoplesoft.pt.xmlpublisher.XMLPUtil");
&bRet = &joUtil.processZipUtilCommand("-extract " | &sZipFilePath | " " | &sOuptutDirName);
    
    
/*If unsuccesfully unzipped then write errors to file.*/
If Not &bRet Then
   MessageBox(0, "", 0, 0, "The Zip file: " | &DataFileName | " was not extracted successfully.");
   &LogFile.WriteLine("The Zip file: " | &DataFileName | " was not extracted successfully.");
End-If;

Limit characters in a long edit box

< script language="text/javascript" >
   //get the outer html
   if(document.getElementById("YOUR_REC_YOUR_FLD$0")!=null)
   {var outerhtm=document.getElementById("YOUR_REC_YOUR_FLD$0").outerHTML;
    //declare our function call
    var addedText= " onchange=this.focus; onkeyup=this.focus; onblur=parseText(this); "
    // reconstruct the outer htm
    outerhtm=outerhtm.substring(0,outerhtm.indexOf(">"))+addedText+ outerhtm.substring(outerhtm.indexOf(">"),outerhtm.length);
    //assign the reconstructed htm.
   document.getElementById("YOUR_REC_YOUR_FLD$0").outerHTML=outerhtm;
   }
   
   function parseText(textElem)
   {//this function does the length checking for objects defined in the case statements below. 
   switch(textElem.name)
    {
    case "YOUR_REC_YOUR_FLD$0":
     if(textElem.value.length >650 ){alert("Short Description has a maximum length of 650 characters\nIt is currently "+textElem.value.length+" characters.");textElem.style.background="red";textElem.focus();}
     else{textElem.style.background="white";}
    break;
    }
   }
< /script >