Florin M.
Florin M.

Reputation: 2169

xpages showing an element depending on two dates

My desire is to show/hide a div element depending on two inputTexts having <xp:convertDateTime pattern="dd/MM/yyyy">. These fields are binded to some sessionScopes and they are displayed using dialog element.

So, I tried the following code inside the div rendered property:

var data1 = sessionScope.searchDate1;
//var data1 = getComponent("inputText3").getValue(); 
var data2 = sessionScope.searchDate2;
//var data1 = getComponent("inputText4").getValue();

if (( data1 != "") && (data2 != ""))
{
if (@Date(data1).before( data2 ) ||  @Date(data1).equals( data2 ))
    { return true; }

else 
    {return false; }
}

Every inputText event ( onChange) will refresh the mainpanel of the dialog, which contains the div also.

I'm getting : '@Date()' is null. Is this because I'm showing firstly the dialog? How can I achieve this?

Upvotes: 1

Views: 50

Answers (1)

Frantisek Kossuth
Frantisek Kossuth

Reputation: 3524

Change

if (( data1 != "") && (data2 != ""))

to

if (data1 && data2)

Upvotes: 1

Related Questions