Friday, November 2, 2007

Setting the default selected date for an OAMessageDateFieldBean

I have seen couple of threads in recent past on OA Forums about setting default value in OAMessageDateFieldBean, so, did a little R n D :) on OAMessageDateFieldBean.

OAMessageDateFieldBean in framework, u will find its nothing but a onClick js event is called on the imageicon attached with messagetextinput bean(in case the type is Date) and OAInlineDatePickerBean is opened in a modal js window.

Setting deafult date in the OAMessageDateFieldBean, also sets the OAInlineDatePickerBean , as it takes the default value from OAMessageDateFieldBean.
So, here is code for setting/getting value both in both in OAMessageDateFieldBean and OAInlineDatePickerBean :
import java.sql.Date;
import java.text.SimpleDateFormat;
java.sql.Timestamp;

//defining format of date
SimpleDateFormat f = new SimpleDateFormat("mm/dd/yyyy");
//define date as string
String dateString = "06/30/1984";
//defining new java.sql.date
Date sqlDate=new Date(f.parse(dateString).getTime());


OAMessageDateFieldBean dateField = (OAMessageDateFieldBean)webBean.findIndexedChildRecursive();
dateField.setValue(pageContext,sqlDate);


//getting oracle.jbo.domain.Date object from OAMessageDateFieldBean
//in process form request
Timestamp ts = (Timestamp)dateField.getValue(pageContext);
System.out.println(ts.getTime());
java.sql.Date select = new java.sql.Date(ts.getTime());
oracle.jbo.domain.Date sd=new oracle.jbo.domain.Date(select);

//You can also set min Value and Max value in OAMessageDateFieldBean which
//will also be set in OAInlineDatePickerBean
//Here is code
dateField.setMinValue(minDate);
dateField.setMaxValue(maxValue);


I hope this helps all.

13 comments:

  1. hi mukul,
    iam new to OAF.i want convert java file to class file how to covert using jad.

    ReplyDelete
  2. Ram,
    You can use command
    Jad –r –s .java **/*.class

    for decompiling class files to java on command prompt in windows.You can also try downloading CAVAJ, which has windows GUI and provides drag and drop functionality. It also based on jad in core.
    --Mukul

    ReplyDelete
  3. hi mukul,
    where we have to write this code.

    regards
    ram

    ReplyDelete
  4. Ram, which code? i think i have mentioned all the steps. WHat's ur exact requirement?
    --Mukul

    ReplyDelete
  5. Hi Mukul,
    I am using body bean onload function.It's working fine in IE and Mozilla 1.5.
    Now the problem getting with Mozilla 3.
    I have check the OAF pages with fire bug, it gives onload error.
    Please help me to resolve

    ReplyDelete
  6. CNU,
    Can you in detail tell what function ur using in onload, and what error ur facing in it in firefix 3

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. I have done just the same you have mentioned in process request and has used set forward url to current page in process form request and it works fine from backend.But on server from front end it does nothing.What I could have missed??

    ReplyDelete
  9. Setting the default selected date for an OAMessageDateFieldBean"
    ---
    I want to set default value on to the OAMessageDateFieldBean, but i am using the bean inside the advanced table and has written a below code..

    SimpleDateFormat f = new SimpleDateFormat("mm/dd/yyyy");
    String dateString = "06/06/2011";
    Date sqlDate = null;
    try
    {
    sqlDate=new Date(f.parse(dateString).getTime());
    System.out.println("sqlDate::"+sqlDate);
    }
    catch (Exception e)
    {

    e.printStackTrace();
    }

    OAAdvancedTableBean advTableBean = (OAAdvancedTableBean)webBean.findChildRecursive("AdvTblRN");
    OAColumnBean columnBean1 =
    (OAColumnBean)advTableBean.findIndexedChildRecursive("column1");
    OAMessageDateFieldBean dateField = (OAMessageDateFieldBean)columnBean1.findIndexedChildRecursive("startdate1");
    dateField.setValue(pageContext,sqlDate);

    and i am unable to get the default value on the bean..please guide me in this.

    ReplyDelete
  10. Hi,
    did anybody corrected Firefox bug with OAInlineDatePickerBean ???
    thanks

    ReplyDelete
  11. Hi Mukul,

    I have one field quantity his database datatype is varchar2, I want to display this quantity field as number format like 55,555.55 on oaf page in advancedtable column field.

    ActualQuantityItem is mapped with quantity column in database
    I tried using fallowing code but not succeed to Format this field please help me on that.

    In PR

    Formatter formatter = new OADecimalValidater("#,##0.00", "#,##0.00");
    OAMessageTextInputBean ActualQuantityBean = (OAMessageTextInputBean)webBean.findChildRecursive("ActualQuantityItem");
    if (ActualQuantityBean != null) {
    ActualQuantityBean.setAttributeValue(UIConstants.ON_SUBMIT_VALIDATER_ATTR, formatter);
    }

    ReplyDelete
  12. Hi Mukul,

    I have to set Sysdate as Default date in MessageTextInput field which data type is Date.

    But am not able to set it b'se type conversion.

    Could you help me in this.

    ReplyDelete