Date Validation by conversion in my OAF page

I had a requirement in OAF page to have a Validation for Effective Start Date and Effective End date in my page.

Here I got my friends help and this is the code I got from him to obtain the date to have validation

Date ddate = (Date)am.findViewObject(“xxCactBankCreateVO”).first().getAttribute(“Dob”);
Date adate = (Date)am.findViewObject(“xxCactBankCreateVO”).first().getAttribute(“ApplDate”);

In the above code I was able to get the date from the VO which I was using. But my requirement was validate it while typing, So I have to get the value from the page.

The problem I faced..

Now after getting the value from the page which was String and the date which I got from the database was returning Date in oracle.jbo.domain.Date. I got struck. Then I got an idea to change the String to date in java.util.Date. Then I changed the database oracle.jbo.domain.Date to String then to java.util.Date. By converting to java.util.Date I can use validation methods.

The code is given below to validate

if(pageContext.getParameter(EVENT_PARAM).equals(“eedate”))  //EEDAte Event occured


java.util.Date  eedate=null;

java.util.Date cdate=null;

System.out.println(“The date has Been Typed”+pageContext.getParameter(“EffectiveEndDate1”));


String start_dt = (pageContext.getParameter(“EffectiveEndDate1”)).toString();           //Obtaining the Date from the user Input for verification

DateFormat formatter = new SimpleDateFormat(“dd-MMM-yyyy”); //Formatting  –> Have to dig inside it   yyyy-MM-dd

eedate = (java.util.Date)formatter.parse(start_dt);           //Conversion of String to Date

System.out.println(“Output for Date lets check”+eedate);

/*Getting Current Date from DB*/

OADBTransaction txn=(OADBTransaction) am.getOADBTransaction();  //Getting Transaction Object to obtain DB time

oracle.jbo.domain.Date currDate=txn.getCurrentDBDate();       //Obtaining Current date

String currdate1=currDate.toString();   //Convering to String to make to java.util.Date

System.out.println(“Current Date is “+currdate1);

currdate1=currdate1.substring(0, 10);    //Eliminating the time From date


DateFormat formatter1 = new SimpleDateFormat(“yyyy-MM-dd”);

cdate = (java.util.Date)formatter1.parse(currdate1);   //Gets converted

System.out.println(“Output for Date lets check”+cdate);    //Testing Output


catch(ParseException e)


System.out.println(“Exception Occured during Date “+e);




System.out.println(“Date is invalid”);

OARow row=(OARow)votest.getCurrentRow();

OAViewObject vo=(OAViewObject)am.findViewObject(“DocLibVO”);   //Getting row from the view object for attribute Exception

// OAEntityImpl eo=null;          //Using a EO Attribute Exception

/* Throwing a Attribute Exception for selecting the wrong date*/

throw new OAAttrValException (

OAException.TYP_VIEW_OBJECT, // indicates VO row source

“DocLibVO”, //View Object full usage name

row.getKey(), // row primary key

“EffectiveEndDate”, //attribute name

(pageContext.getParameter(“EffectiveEndDate1”)).toString(), // bad attribute value

“AK”, //message application short name

“ATTR_EXCEPTION”); // message name

//            eo.setAttributeInternal(“EffectiveEndDate”, (pageContext.getParameter(“EffectiveEndDate1”)).toString());




System.out.println(“Date is valid”);


}       //End of Effective End Date event

Then I got a problem when using Attribute Exception.  The problem is I was not able to display the error near the attribute. The screen shot is shown below

DateValidation and Calender settings

The problem for displaying the error near the attribute was not solved.


About pacesettergraam

A good and realistic person

Posted on November 29, 2013, in OAF, Oracle and tagged , , , , , , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: