Wednesday, 5 November 2014

Date picker will allow Today and Tomorrow Dates only in ADF

I have validation, the date field should allow today and tomorrow dates only.
For the see the following code:

in java bean code:

    public Date getMinDate() {
        try {
            Calendar now = Calendar.getInstance();
            java.util.Date date = now.getTime();
            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
            String currentDate = formatter.format(date);
            return formatter.parse(currentDate);
        } catch (Exception e) {
            return null;
        }
    }
    public Date getMaxDate(){
        Calendar c = Calendar.getInstance();
        c.setTime(new Date()); // Now use today date.
        c.add(Calendar.DATE, 1); // Adding 1 days
        return c.getTime();
       
    }

jspx code:

 <af:inputDate value="#{bindings.StartDate.inputValue}"  label="#{bindings.StartDate.hints.label}"
                        minValue="#{viewScope.MyBean.minDate}" maxValue="#{viewScope.MyBean.maxDate}"
                          required="#{bindings.StartDate.hints.mandatory}" shortDesc="#{bindings.StartDate.hints.tooltip}"
                          id="id3">
              <f:validator binding="#{bindings.StartDate.validator}"/>
              <af:convertDateTime pattern="#{bindings.StartDate.format}"/>
            </af:inputDate>

Tuesday, 28 October 2014

How to set pivot table content dynamically in ADF

I will describe the how to set pivot table value at runtime .

My requirement is I have one drop down based on the user selection populate the pivot table content at runtime.
Here I am taking HR schema. There I created Employee and Deparment VOs.


Next I am adding the VOs as pivot table bindings to my page def file.
Click the add button from bindings section and select the ADF data visualization bindings.




 There Select the pivot table bindings and add which vo you want create pivot table and choose the columns drag and drop to the table.



 



 
Selete next all and finish it. Like this do the same for Employee.
Now am create drag and drop pivot table form component palette. jspx page code here.



 
The pivot table value attribute is bind to managed bean so now am set the value in managed based my drop down selection.

 private PivotTableModel activePivotTabVal;


    public void setActivePivotTabVal(PivotTableModel activePivotTabVal) {
        this.activePivotTabVal = activePivotTabVal;
    }
    public PivotTableModel getActivePivotTabVal() {
        return activePivotTabVal;
    }


    public void changeEvent(ValueChangeEvent valueChangeEvent) {
       String str = valueChangeEvent.getNewValue().toString();
       String expValue = "";
       if(str.equals("emp")){
           expValue = "#{bindings.EmployeesView1.pivotTableModel}";
       }else if(str.equals("dep")){
           expValue = "#{bindings.DepartmentsView1.pivotTableModel}";
       }
       activePivotTabVal = (PivotTableModel)resolveExpression(expValue);
        pivotTable.setVisible(true);
       AdfFacesContext.getCurrentInstance().addPartialTarget(pivotTable);
    }

Run the application. first my screen is



 
After user select the value from drop down, populate the content ...
 



 
 
 
I hope this post is useful when you have this kind of req....