Question
Last activity: 28 Jul 2017 11:04 EDT
How to get the code from auto generated controls
Hi,
There is a control to display time in drop downs. This is an auto generate control. I would like to know how to get the code for the control as I need to do some customization.
Regards
Raj


Cognizant Technology Solutions
GB
Hi ,
I am trying to get the code for the control "DateTime"
Regards
Raj


Cognizant Technology Solutions
GB
Field"
var field = document.getElementById(ID);
if (field){
return field.value;
}
else{
return "";
}
}
function DateTime_setValue(val){
var ID="calField"
var field = document.getElementById(ID);
if (field){
field.value = val;
}
}
function DateTime_setFocus(){
var ID="calField"
var field = document.getElementById(ID);
if ((field.tagName == "INPUT") || (field.tagName == "input")){
field.focus();
}
}
//-->
= 0) { /* auto */
strInputWidth = "auto";
strTDWidth = "auto";
tools.putSaveValue("strExpectedWidth","auto");
}
}
tools.putSaveValue("strInputWidth",strInputWidth);
tools.putSaveValue("strTDWidth",strTDWidth);
%>
0 && curProp.hasValidValue() && curProp.toDate()!=null) {
String sDatetime="";
String type = tools.getParamValue("DateTimeFormat");
String strTimeZone = "GMT";
if(curProp.getType() == PropertyInfo.TYPE_DATETIME){
strTimeZone = tools.findPage("pxRequestor").getString(".pyUseTimeZone");
}
if(type.equals("1")){//DateTime-Short
sDatetime = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATETIME_SHORT, curProp.toDate());
}
else if(type.equals("2") || type.equals("")){ //DateTime-Short-YYYY
sDatetime = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATETIME_SHORT_YYYY, curProp.toDate());
}
else if(type.equals("3")){ //DateTime-Default or DateTime-Medium
sDatetime = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATETIME_DEFAULT, curProp.toDate());
}
else if(type.equals("4") ){ //DateTime-Long
sDatetime = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATETIME_LONG, curProp.toDate());
}
else if(type.equals("5")){ //DateTime-Full
sDatetime = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATETIME_FULL, curProp.toDate());
}
tools.putSaveValue("result",sDatetime);
}
else {
String sDatetime="";
Date tempDate = PRDateFormat.parseInternalDateTime(tools.getActiveValue());
if(tempDate != null)//Check if its a valid date time
{
String type = tools.getParamValue("DateTimeFormat");
String strTimeZone = tools.findPage("pxRequestor").getString(".pyUseTimeZone");
if(type.equals("1")){//DateTime-Short
sDatetime = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATETIME_SHORT, curProp.toDate());
}
else if(type.equals("2") || type.equals("")){ //DateTime-Short-YYYY
sDatetime = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATETIME_SHORT_YYYY, curProp.toDate());
}
else if(type.equals("3")){ //DateTime-Default or DateTime-Medium
sDatetime = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATETIME_DEFAULT, curProp.toDate());
}
else if(type.equals("4") ){ //DateTime-Long
sDatetime = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATETIME_LONG, curProp.toDate());
}
else if(type.equals("5")){ //DateTime-Full
sDatetime = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATETIME_FULL, curProp.toDate());
}
tools.putSaveValue("result",sDatetime);
}
else{
tools.putSaveValue("result",tools.getActiveValue());
}
}
%>
0 && curProp.hasValidValue() && curProp.toDate()!=null) {
String sDate="";
String type = tools.getParamValue("DateFormat");
String strTimeZone = "GMT";
if(curProp.getType() == PropertyInfo.TYPE_DATETIME){
strTimeZone = tools.findPage("pxRequestor").getString(".pyUseTimeZone");
}
if(type.equals("1")){ //Date-Short
sDate = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATE_SHORT_YY , curProp.toDate());
}
else if(type.equals("2") || type.equals("")){ //Date-Short-Default
sDate = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATE_SHORT_YYYY, curProp.toDate());
}
else if(type.equals("3") ){ //Date-Medium
sDate = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATE_MEDIUM , curProp.toDate());
}
else if(type.equals("4")){ //Date-Long
sDate = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATE_LONG , curProp.toDate());
}
else if(type.equals("5")){ //Date-Full
sDate = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATE_FULL , curProp.toDate());
}
tools.putSaveValue("result",sDate);
}
else {
String sDate="";
Date tempDate= PRDateFormat.parseInternalDate(tools.getActiveValue());
String strTimeZone = tools.findPage("pxRequestor").getString(".pyUseTimeZone");
if(tempDate != null){
String type = tools.getParamValue("DateFormat");
if(type.equals("1")){ //Date-Short
sDate = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATE_SHORT_YY , curProp.toDate());
}
else if(type.equals("2") || type.equals("")){ //Date-Short-Default
sDate = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATE_SHORT_YYYY, curProp.toDate());
}
else if(type.equals("3") ){ //Date-Medium
sDate = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATE_MEDIUM , curProp.toDate());
}
else if(type.equals("4")){ //Date-Long
sDate = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATE_LONG , curProp.toDate());
}
else if(type.equals("5")){ //Date-Full
sDate = PRDateFormat.format(null, strTimeZone, PRDateFormat.DEFAULT_DATE_FULL , curProp.toDate());
}
tools.putSaveValue("result",sDate);
}else{
tools.putSaveValue("result",tools.getActive().getStringValue());
}
}
%>
" size=""
RHP_NAME="!DateTimeFormat=!Size=!CalculatedValue=" class='dataLabelCalculatedValue' >
"
type="text" name="" ID="calField" value="" style='width:' > |
|
Clicked ( )
{
window.dateField = document.getElementById( "calField" );
">
// var url = "";
<%
if(tools.getParamValue( "DateTimeFormat" ).length() == 0 )
tools.putParamValue("DateTimeFormat", 2);
%>
var url = new SafeURL("ShowCalendar");
url.put("CalendarHTML", "NewCalendarDateTime");
url.put("DateFormat", <%= StringUtils.crossScriptingFilter(tools.getParamValue("DateTimeFormat")) %> );
openUrlInWindow( url, 'Calendar','status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,WIDTH=250,HEIGHT=350' );
//-->
// var url = "";
var url = new SafeURL("ShowCalendar");
url.put("CalendarHTML", "NewCalendarDate");
url.put("DateFormat", );
openUrlInWindow( url, 'Calendar','status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,WIDTH=250,HEIGHT=350' );
// var popWindow = window.open( url, 'Calendar','status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,WIDTH=250,HEIGHT=350');
}
Field" ).disabled = true;
//-->
Field" ).style.display = "none";
'>
document.getElementById( "calIcon" ).style.display = "none";
//-->
<%
tools.appendString("var localDateArray = new Array(");
int end = 59;
for(int i=0; i<= end; i++)
{
if( i == end )
tools.appendString("'"+com.pega.pegarules.pub.util.PRNumberFormat.format(null, com.pega.pegarules.pub.util.PRNumberFormat.DEFAULT_INTEGER, false, null, i) + "');");
else
tools.appendString("'"+com.pega.pegarules.pub.util.PRNumberFormat.format(null, com.pega.pegarules.pub.util.PRNumberFormat.DEFAULT_INTEGER, false, null, i) + "',");
};
int firstDayOfWeek = (PRDateFormat.getFirstWeekDay(null) - 1);
tools.appendString( "\nvar firstDayOfTheWeek = " + firstDayOfWeek + ";" );
tools.appendString( "\nvar shortDateFormat = " +"\"" +com.pega.pegarules.pub.util.PRDateFormat.getShortDateFormat(null)+ "\""+ ";");
tools.appendString( "\nvar shortDateTimeFormat = " +"\"" +com.pega.pegarules.pub.util.PRDateFormat.getShortDateTimeFormat(null)+ "\""+ ";");
tools.appendString( "\nvar closeText = " + "\"" + tools.getLocalizedTextForString("pxRequestor.pyButtonLabel","Close") + "\";" );
tools.appendString( "\nvar todayText = " + "\"" + tools.getLocalizedTextForString("pxRequestor.pyButtonLabel","Today") + "\";" );
String months[] = PRDateFormat.getMonths(null);
tools.appendString("\nvar longMonthArray = new Array(");
for(int i=0; i < months.length; i++)
{ if ( i != 0 )
tools.appendString( "," );
String month = months[i];
if ( month.length() != 0 )
month = ( month.substring( 0, 1 ).toUpperCase() + month.substring( 1, month.length() ) );
tools.appendString("'" + month + "'" );
};
tools.appendString( ");" );
tools.appendString("\nvar shortMonthArray = new Array(");
for(int i=0; i < months.length; i++)
{ if ( i != 0 )
tools.appendString( "," );
String month = months[i];
if ( month.length() != 0 )
{ month = month.substring( 0, 1 ).toUpperCase();
int endIndex = (int)Math.min( months[i].length(), 3 );
if ( endIndex > 1 )
month += months[i].substring( 1, endIndex );
}
tools.appendString("'" + month + "'" );
};
tools.appendString( ");" );
String initialWeekdays[] = PRDateFormat.getWeekdays(null);
int daysInWeek = initialWeekdays.length;
String[] weekdays = new String[daysInWeek];
int count = 0;
for(int startIndex = firstDayOfWeek; startIndex < daysInWeek; startIndex++)
weekdays[count++] = initialWeekdays[startIndex];
for(int startIndex2 = 0; startIndex2 < firstDayOfWeek; startIndex2++)
weekdays[count++] = initialWeekdays[startIndex2];
boolean comma = false;
tools.appendString("\nvar oneCharDayArray = new Array(");
for(int i=0; i < daysInWeek; i++)
{ if ( weekdays[i] == null || weekdays[i].length() == 0 )
continue;
if ( comma )
tools.appendString( "," );
String day = ( weekdays[i].substring( 0, 1 ).toUpperCase() );
tools.appendString("'" + day + "'" );
comma = true;
};
tools.appendString( ");" );
String initialShortWeekdays[] = PRDateFormat.getShortWeekdays(null);
String shortWeekdays[] = new String[daysInWeek];
count=0;
for(int startIndex = firstDayOfWeek; startIndex < daysInWeek; startIndex++)
shortWeekdays[count++] = initialShortWeekdays[startIndex];
for(int startIndex2 = 0; startIndex2 < firstDayOfWeek; startIndex2++)
shortWeekdays[count++] = initialShortWeekdays[startIndex2];
comma = false;
tools.appendString("\nvar shortDayArray = new Array(");
for(int i=0; i < daysInWeek; i++)
{ if ( shortWeekdays[i] == null || shortWeekdays[i].length() == 0 )
continue;
if ( comma )
tools.appendString( "," );
String day = ( shortWeekdays[i].substring( 0, 1 ).toUpperCase() + shortWeekdays[i].substring( 1, shortWeekdays[i].length() ) );
tools.appendString("'" + day + "'" );
comma = true;
};
tools.appendString( ");" );
comma = false;
tools.appendString("\nvar medDayArray = new Array(");
for(int i=0; i < daysInWeek; i++)
{ if ( weekdays[i] == null || weekdays[i].length() == 0 )
continue;
if ( comma )
tools.appendString( "," );
String day = ( weekdays[i].substring( 0, 1 ).toUpperCase() + weekdays[i].substring( 1, 3 ) );
tools.appendString("'" + day + "'" );
comma = true;
};
tools.appendString( ");" );
comma = false;
tools.appendString("\nvar longDayArray = new Array(");
for(int i=0; i < daysInWeek; i++)
{ if ( weekdays[i] == null || weekdays[i].length() == 0 )
continue;
if ( comma )
tools.appendString( "," );
String day = ( weekdays[i].substring( 0, 1 ).toUpperCase() + weekdays[i].substring( 1, weekdays[i].length() ) );
tools.appendString("'" + day + "'" );
comma = true;
};
tools.appendString( ");" );
String ampm[] = PRDateFormat.getAmPmStrings(null);
tools.appendString("\nvar ampmArray = new Array(");
for(int i=0; i < ampm.length; i++)
{ if ( i != 0 )
tools.appendString( "," );
tools.appendString("'" + ampm[i] + "'" );
};
tools.appendString( ");" );
%>
var calendarType = "";
var b12Hour = true;
if (calendarType != "Date")
{ var hourIndex = shortDateTimeFormat.indexOf("hh");
if(hourIndex == -1)
{ hourIndex = shortDateTimeFormat.indexOf("h");
if(hourIndex == -1)
{ hourIndex = shortDateTimeFormat.indexOf("H");
b12Hour = false;
}
}
var ampmIndex = shortDateTimeFormat.indexOf("a");
if(ampmIndex == -1)
b12Hour = false;
}
// Locale Specific Configuration
pega.ui.Calendar.prototype.customConfig = function()
{
this.Config.Locale.SHORT_DATE_FORMAT = shortDateFormat;
this.Config.Locale.SHORT_DATE_TIME_FORMAT = shortDateTimeFormat;
this.Config.Locale.AMPM_TEXT = ampmArray;
this.Config.Locale.MONTHS_SHORT = shortMonthArray;
this.Config.Locale.MONTHS_LONG = longMonthArray;
this.Config.Locale.WEEKDAYS_1CHAR = oneCharDayArray;
this.Config.Locale.WEEKDAYS_SHORT = shortDayArray;
this.Config.Locale.WEEKDAYS_MEDIUM = medDayArray;
this.Config.Locale.WEEKDAYS_LONG = longDayArray;
this.Config.Locale.CLOSE_TEXT = closeText;
this.Config.Locale.TODAY_TEXT = todayText;
this.Config.Locale.LOCAL_DATE_ARRAY = localDateArray;
this.Config.Options.TWELVE_HOUR = b12Hour;
this.Config.Options.START_WEEKDAY = firstDayOfTheWeek;
}
var showingPegaCal = null;
function hideCurrentCalendar ( )
{ if ( showingPegaCal != null )
{ if ( showingPegaCal.clicked )
showingPegaCal.clicked = false;
else
{ showingPegaCal.hide();
showingPegaCal = null;
if(pega.u&&pega.u.d)
pega.u.d.resizeHarness();
}
}
}
function newCalendar_documentBodyClicked()
{ hideCurrentCalendar();
}
document.body.onclick = function()
{ newCalendar_documentBodyClicked();
}
var pegaCalFirstInit = true;
<%
if( tools.getParamValue( "DateTimeFormat" ).length() == 0 )
tools.putParamValue( "DateTimeFormat", 2 );
if( tools.getParamValue( "DateFormat" ).length() == 0 )
tools.putParamValue( "DateFormat", 2 );
ClipboardProperty curProp = tools.getActive();
if((curProp.getType() == PropertyInfo.TYPE_DATE || curProp.getType() == PropertyInfo.TYPE_TEXT ) && StringUtils.crossScriptingFilter(tools.getParamValue("DateFormat")) != "" )
tools.appendString("var dateFormat = " + StringUtils.crossScriptingFilter( tools.getParamValue( "DateFormat" )) + ";");
if (curProp.getType() == PropertyInfo.TYPE_DATETIME ||(curProp.getType() == PropertyInfo.TYPE_TEXT && StringUtils.crossScriptingFilter(tools.getParamValue("DateTimeFormat")) != "" ))
tools.appendString("var dateFormat = " + StringUtils.crossScriptingFilter( tools.getParamValue( "DateTimeFormat" ))+ ";");
%>
var thisPropName = "";
<%tools.putSaveValue("calName", "cal" + tools.getActive().getEntryHandle()); %>
var calName = "cal"+thisPropName;
var dateField = document.getElementById( calName + "Field" );
var displayMode = "<%=tools.getParamValue("DisplayMode")%>";
try{
var <%=tools.getSaveValue("calName")%> = new pega.ui.Calendar( '<%=tools.getSaveValue("calName")%>', dateField, <%=HP_DT_ShowTime%>, displayMode, dateFormat);
//eval( "var " + calName + " = new pega.ui.Calendar( '" + calName + "', dateField, <%=HP_DT_ShowTime%>, '" + displayMode + "' );" );
if ( dateField.value.length != 0 )
<%=tools.getSaveValue("calName")%>.setDate( dateField.value );
}
catch(exception){
}
//-->
" style="display:none">
Hi Kautuseth,
Thanks for your support. I tried to save this code in a control rule but it was throwing the following errors. Basically my requirement is to shoe only 00,15,30,45 values in the minutes dropdown instead of 00-59 values.
Test compilation failed: ----------
1. ERROR in /Rule_HTML_Property_DisplayCustomTime_Stream_20170728T121533_073_GMT.java (at line 116)
String strExpectedSize = tools.getSaveValue("strExpectedSize");
^^^^^^^^^^^^^^^
Duplicate local variable strExpectedSize
----------
2. ERROR in /Rule_HTML_Property_DisplayCustomTime_Stream_20170728T121533_073_GMT.java (at line 238)
ClipboardProperty curProp = tools.getActive();
^^^^^^^
Duplicate local variable curProp
----------
3. ERROR in /Rule_HTML_Property_DisplayCustomTime_Stream_20170728T121533_073_GMT.java (at line 460)
ClipboardProperty curProp = tools.getActive();
^^^^^^^
Duplicate local variable curProp
----------
3 problems (3 errors)
Compile failed.


Cognizant Technology Solutions
GB
Why don't you try to use a local list and a drop down,, and you will be able to capture the value on select/on change/on click,,,, one of those events.
let me know if this does not sort your issue, we will try some other option.
What is the name of the control that you are referring to please?