<xp:validateExpression
message="İzinler pazar günü başlayamaz.">
<xp:this.expression><![CDATA[#{javascript:var DateConverter = {
dateToString: function( date:java.util.Date, pattern:String ){
try {
if( !date ){ return ''; }
var formatter = DateConverter.getFormatter( pattern );
return formatter.format( date );
} catch( e ){
// ErrorHandling
}
},
stringToDate: function( dateString:String, pattern:String ){
try {
if( !dateString ){ return null; }
var formatter = DateConverter.getFormatter( pattern );
return formatter.parse( dateString );
} catch( e ){
// ErrorHandling
}
},
getFormatter: function( pattern:String ){
try {
var cacheKey = 'dateFormatter' + pattern;
var dateFormatter = applicationScope[ cacheKey ];
if( !dateFormatter ){
dateFormatter = new java.text.SimpleDateFormat( pattern );
applicationScope[ cacheKey ] = dateFormatter;
}
return dateFormatter;
} catch( e ){
// ErrorHandling
}
}
};
vDate = DateConverter.stringToDate(getComponent("LeaveDate").getSubmittedValue(), 'dd.MM.yyyy' );
return (@Weekday(vDate) != 1);
}]]></xp:this.expression>
I'm trying to add a validation to restrict the selection of sundays. But expression returns True regardless of date I select.
The snippet above is to convert string to date, because I read that getSubmittedValue() returns string regardless of the source field type.
return (@Weekday(getComponent("LeaveDate").getSubmittedValue()) != 1);
My first code was this but I couldn't get it work either.