cancel
Showing results for 
Search instead for 
Did you mean: 

A problem regarding Date?

Former Member
0 Kudos

hi

I have made a input fieldUI element of type date.I want a error to come when user dosenot enter this field .

I am doing it in this fashion:

view.java

//wdInit()

{

this.intialize();

}

//

void intialize()

{

wdContext.currentcontextElement.setInputfield(new Date(0));

}

//void checkMandotry(java.lang.FieldName)

{

all that to generate error message.

}

//onMyActionClick

void onMyActionclick()

{

Date date1=wdContext.currentelement.getAttributeValue();

if(date1.equals(new Date(0))

{

this.CheckMandotry()

}

}

But in my application 01/01/1970 comes by default on my inputfield which i donot want?

How to do this?

Please help me

regards

Nidhideep

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

//To Get Blank value in Date Field Use

wdContext.currentcontextElement.setInputfield(null);

//To Get the current Date

wdContext.currentcontextElement.setInputfield(new Date());

Kind Regards

Mukesh

Former Member
0 Kudos

hi

Mukesh ,I was able to solve my problem but a new problem has arised.I have three inputfield of type date.

for eg. orderdate,shipmentdate,mturitydate.My logic is:

onSomeAction

{

if(orderdate ==null||shipmentdate==null|| maturitydate==null)

{

some error arises

}

if(orderdate.before(shipmentdate)||maturitydate.before(shipmentdate)

{

some error arsises

}

But i am getting a Nullpointer exception.

Please help me.

Regards

Nidhideep

Former Member
0 Kudos

Hi,

Are you intialized the date attibute with null?

Regards

Saravanan K

Former Member
0 Kudos

Hi

When you check

Before assign the value check the context value is null.

Date orderdate =null;

if(wdContext.current<node>Element().getorderdate()!=null){

orderdate=wdContext.current<node>Element().getorderdate();

}else{

//Do the Rest

}

if(orderdate ==null||shipmentdate==null|| maturitydate==null)

{

//some error arises

}

what error occurs?

//before the condition check the null value

if(orderdate!=null && shipmentdate!=null && maturitydate!=null){

if(orderdate.before(shipmentdate)||maturitydate.before(shipmentdate)

{

//some error arsises

}

}

Kind Regards

Mukesh

sridhar_k2
Active Contributor
0 Kudos

Hi Nidhideep,

You are getting NullPointer becaue, you are comparing (before()) with null value.

To Avoid NullPointer you can do this.

<b>if</b>(orderdate == null||shipmentdate == null|| maturitydate == null)

{

//Some Error Msgs

}<b> elseif</b> (orderdate.before(shipmentdate)||maturitydate.before(shipmentdate))

){

//Some Error Msgs

}

Hope it may solved ur problem.

Regards,

Sridhar

Former Member
0 Kudos

hi

Thanx to all of you for so much support.I have solved my problem and also given respective points all of u.

Thanx again.

Regards

Nidhideep

Answers (3)

Answers (3)

sridhar_k2
Active Contributor
0 Kudos

Hi,

You can use the below code to check.

If you dont want to see anything in the input field, just dont intialize with any value in the intialize().

Date dd = wdContext.currentContextElement().getDate1();

if(dd == null ){

wdComponentAPI.getMessageManager().reportSuccess("Empty");

checkRequired();

}else{

wdComponentAPI.getMessageManager().reportSuccess("Not Empty");

}

Regards,

Sridhar

Message was edited by: Sridhar kanchanapalli

Message was edited by: Sridhar kanchanapalli

Former Member
0 Kudos

Hi,

I think you can intialize date attribute with null

Regards

Saravanan K

former_member182372
Active Contributor
0 Kudos

Hi Nidhideep,

Instead of

new Date(0)

use just

new Date()

and it will come with current date.

Best regards, Maksim Rashchynski.