Thursday, 6 November 2014

Disable Past dates and future dates in ADF Input Date

Hi all, In today's post i am going to explain you how to disable past date and future date for Input Date component. Sometime you get requiment to disable the past dates and future date also. This post can help you.

My requirement is to show only today and tomorrow's date and rest all need to disable. User should not select othere then these dates.
There are two attributes in inputDate component MinValue and MaxValue.

1. MinValue attribute is used to disable the back dates.

2. MaxValue attribute is used to disable the forward dates.

I have create one bean and two methods as show below

  private Date minDate = new Date();

    public Date getMaxDateVal() {
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        cal.add(Calendar.DATE, 1); 
        return cal.getTime();


cal.add(Calendar.DATE, 1);  // how many forwarding dates need to enable, In my requirement i should show tomorrow date, sho i have mentioned "1".

    public Date getMinDate() {
    try {
                Calendar cal = Calendar.getInstance();
    java.util.Date date = cal.getTime();
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
                String currentDate = formatter.format(date);
    minDate = formatter.parse(currentDate);
    return formatter.parse(currentDate);
            } catch (Exception e) {
    return null;

jspx page code is  below.

 <af:inputDate label="Label 1" id="id1"

 Run the page.

Thanks :)  Happy Learning :)

Tuesday, 4 November 2014

Setting session scope variable to ADF BC View Object bind variable

In this post i am going to explain you how to set the session scope value to ADF BC View Object bind variable. Some times most of the View Objects will be based on some criteria and the bind variable value should based on specific user login. In this case follow the below steps.
Firstly I would like to thank for writing this post andrejusb post. But in this post he didn't describe about setting the session scope value to view object. If you have simillar requirement follow the below steps.

To set variable in session scope i have used the below code in the managed bean on button click. You can also use Managed bean which is in the session sope.

Now create bind variable in view object and set the expession shown below.

I used Department table here. Modify accordingly based on your use case.

Thanks :) and Happy Learning :)