cancel
Showing results for 
Search instead for 
Did you mean: 

Date in past - validation

Former Member
0 Kudos

Hi ,

In my webdynpro application, I have a date feild and I need that after user select a date and then submit the form - on submit an method is implemented which checks that the date is either the current date or any date from past user should not select future date ansd in case the date is any future date it shows error message .

For this, I created a message of type error in message pool as - DateInFuture.

then I created a method as - CheckDateInPast()

In implementation of method -

IWDMessageManager msgMgr = this.wdThis.wdGetAPI() .getComponent().getMessageManager();

Date theDate =(Date) this.wdContext.currentContextElement().

getAttributeValue(Date);

IWDAttributeInfo attributeInfo =

this.wdContext.getNodeInfo().getAttribute(Date);

if (theDate.after(new Date(System.currentTimeMillis()))) {

String fieldLabel = this.wdContext.getNodeInfo().getAttribute(Date)

.getSimpleType().getFieldLabel();

msgMgr.reportContextAttributeMessage(

this.wdContext.currentContextElement(),

attributeInfo,

IMessageSimpleErrors.Date_In_Future,

new Object[] {Date, theDate},

true);

The imports - used are

import java.sql.Date;

import com.sap.tc.webdynpro.progmodel.api.IWDAttributeInfo;

import com.sap.tc.webdynpro.progmodel.api. IWDMessageManager ;

The Error I am geting is - IMessageSimpleErrors cannot be resolved..

Please can any one tell what is the problem ???

Thanks,

Gunja

Accepted Solutions (0)

Answers (5)

Answers (5)

former_member201361
Active Contributor
0 Kudos

hi ,

wdContext.currentContextElement().setDateXXX(new Date(0));

will make the date field null. on clicking clear all the previous date will be removed.

hope your problem get resolved

thanks and regards

fazal

former_member201361
Active Contributor
0 Kudos

hi ,

you should import the IMessageErrors

for eg;

import java.sql.Date;

import com.sap.tc.webdynpro.progmodel.api.IWDAttributeInfo;

import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager;

import simpleapp.comp.wdp.IMessageSimpleComp;

import simpleapp.comp.wdp.IPrivateEmailView;

import simpleapp.comp.wdp.IPrivateSimpleCompView;

thanks and regards

fazal

Former Member
0 Kudos

Hi ,

The name of my iview is - POC_compView in POC_comp component.

I have already click the orgnise import option and also added all these imports -

import java.sql.Date;

import com.sap.tc.webdynpro.progmodel.api.IWDAttributeInfo;

import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager;

import com.sap.wdp.IPrivatePOC_compView;

import com.sap.wdp.IMessagePOC_comp;

Still the same error persist....

Please help...

Former Member
0 Kudos

hi,

it will not work with organise imports....

Instead of IMessageSimpleError please use IMessagePOC_comp(whatever your compoennt name is).

The format is IMessage<Componentname>. Please try this once

regards,

pinki

former_member201361
Active Contributor
0 Kudos

hi,

check date in past is well explained in the following tuitorial .

[http://help.sap.com/saphelp_nw04/helpdata/en/d2/5c830ca67fd842b2e87b0c341c64cd/frameset.htm]

in the simple input form tutorial an inputfield with date attribute will be binded and in the checkdateinpast method , we will get a idea to check the date.

right click-->source -->organize imports .

will import the neccessary import required for the class.

hope your problem get resolved

thanks and regards

fazal

Edited by: fazal ahamed on Apr 2, 2008 10:15 AM

Former Member
0 Kudos

hi,

What is the name of the Component in which you have declared the message.

The iterface to be used is "IMessage<yourcomponentname>.<ctrl+space-to get the list of the messaged declared in the message pool of the component>.

Chose the message.

Regards,

pinki

Former Member
0 Kudos

Hi,

Thanks pinki , that error is no more now by using IMessage<Comp name>.<messagename>,...

But can you please tell me while calling this method in the action .

In the implementation of onactionSubmit (...) -

this.CheckDateInPast( string Date);

What should be the Parameter in " String Date "

and One more problem when user click clear all button that has to clear all the feilds -

In this -

//wdContext.currentContextElement().setDate(new Date(0));

//wdContext.currentContextElement().setTime(new Time(0));

But this lines does not clear the date and time but set it to 1/1/1970 and time to 5:30:00 A.M.

Please let me know how this can be solved????

Thanks,

Gunja

Former Member
0 Kudos

Hi ,

To clear Date Use the below code

Date d = null;

wdContext.currentContextElement().setDate(d);

Regards,

Sunitha Hari

Former Member
0 Kudos

hi,

if your first problem was solved, please award points for it.

Secondly,to clear the selection you can use the following code


 java.sql.Date datum = null;
wdContext.currentDropkeyElement().setBirthday(datum);

regards,

pinki

Former Member
0 Kudos

Hi,


java.sql.Date Currentdate = new java.sql.Date( System.currentTimeMillis());
if( wdContext.currentContextElement().getEDIDate_From().compareTo( Currentdate) != 1)
{			wdComponentAPI.getMessageManager().reportSuccess( "Working");
}
else
{
wdComponentAPI.getMessageManager().reportWarning( " current date can not less than from date ");
}
   

The compareTo method return 3 values; it can be 1 if the target date is less to source date; 0 if both dates are same; and -1 if the dates are right in use.

Regards

- Vinod

Edited by: Vinod V on Apr 2, 2008 1:33 PM