Two Ways to Evaluate a Memory Scope Attribute Using Expression Language

All of us know how to evaluate a memory scope attribute using a dot notation syntax of the expression language.

Example: to access a request scope attribute, we use this syntax.

#{requestScope.attributeKey}

However, this syntax fails if the key has a dot (.) in its name. To overcome this limitation, expression language offers the string argument notation.

Example: to access a request scope attribute which has a (.) in its name, we use this syntax.

#{requestScope['attributeKey']}

 

Leave a Comment

Filed under ADF

Create a Backing Bean for Existing Page

A backing bean is a special case of managed bean that has a one-to-one relationship to a single JSF page, and it exposes setter and getter methods for the components contained on the page. In Jdeveloper you can automatically expose UI components in a new bean when you create a new page by setting the Automatically Expose New UI Components in a New Managed Bean option as shown in the figure below.

Automatically Expose New UI Components in a New Managed Bean option

Automatically Expose New UI Components in a New Managed Bean option

But imagine you forget to set this option and later you decided to create a Backing Bean, do you need to explicitly bind each component to the backing bean?

Fortunately, you don’t need to bind the components manually, all you need is to open the page in the visual editor and  choose Design | Page Properties from the Jdeveloper menu bar as shown in the figure below:

Click on the page properties and then select the Component Binding tab from the page properties window, set the Auto Bind option, and create or select an existing managed bean.

expose3

Leave a Comment

Filed under Uncategorized

How to Disable Specific Dates in af:inputDate Component

Environment (JDeveloper 11.1.2.3.0,ADF Faces)

The inputDate component creates a text field for entering dates and (optionally) a glyph which opens a popup for picking dates from a calendar. However  in some cases we need to prevent the user from picking a specific days from the calender. In this post I will explain how to do this use case.

1- Create a simple JSF page and drag and drop af:inputDate component from the component palette into the newly created page.

2- Create a java class which implements org.apache.myfaces.trinidad.model.DateListProvider interface. This interface is used for providing a list of  individual dates within a given range.

3- Override the getDateList method, This method will generate a List of individual Date objects which will be rendered as disabled in a datePicker component.  An example is shown below.

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import javax.faces.context.FacesContext;

import org.apache.myfaces.trinidad.model.DateListProvider;

public class DaysBean
  implements DateListProvider
{
  public DaysBean()
  {
    super();
  }

  @Override
  public List getDateList(FacesContext facesContext, Calendar calendar, Date date, Date date2)
  {
    ArrayList disabledDates= new ArrayList();
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    try
    {
      disabledDates.add(sdf.parse("01/01/2013"));
      disabledDates.add(sdf.parse("25/12/2013"));
    }
    catch (ParseException e)
    {
      e.printStackTrace();
      return Collections.emptyList();
    }
    return disabledDates;
  }
}

4-Register the Java Class as Managed Bean in adfc-config.xml file.

       Register Java Class as Managed Bean in adfc-config.xml file

5- Go to the JSF page and select the inputDate component, from the property inspector select the DisabledDays property and bind it to the manged bean defined in the previous step.

<af:document title="Test.jsf" id="d1">
<af:form id="f1">
<af:inputDate label="Date" id="id1" disabledDays="#{daysBean}"/>
</af:form>
</af:document>

Note:

 this binding requires periodic roundtrips. If you just want to disable certain weekdays (e.g. Saturday and Sunday), use the disabledDaysOfWeek attribute!

6- Run the page, and check that the date is disabled.

01/01/2013 is Disabled

Moreover, if the user enters the date manually without using the date picker, an error message will be shown to the user.

Error Message When the date is Entered Manually

download the sample application TestDisableDays.rar

Please change the file extension to .zip or .rar after download.

Leave a Comment

January 24, 2013 · 10:59 am

Application Development Framework Implementation specialist

Today, I took the Oracle Application Development Framework 11g Essentials exam (1Z0-554). Fortunately I passed it, and I am now an Application Development Framework Implementation specialist.

O_Certified Specialist_clr

4 Comments

Filed under ADF

2012 in review

The WordPress.com stats helper monkeys prepared a 2012 annual report for this blog.

Here’s an excerpt:

4,329 films were submitted to the 2012 Cannes Film Festival. This blog had 50,000 views in 2012. If each view were a film, this blog would power 12 Film Festivals

Click here to see the complete report.

Leave a Comment

Filed under Uncategorized

How to Solve oracle.jbo.ConfigException: JBO-33001

Environment (JDeveloper, ADF BC, ADF Faces)

When you work with large application which contains more than one Model/one ViewController projects, you need to set the project dependency between the model and the view controller project., failing to do this you may face this exception.

oracle.jbo.ConfigException: JBO-33001: Configuration file /model/common/bc4j.xcfg is not found in the classpath.

To solve the problem, double click the viewController project to open project properties dialog, and select the the Dependencies node  and click the Edit Dependecies icon to add a dependency on the build output path or on one or more deployment archives.

Hope this will help someone faced the same problem.

2 Comments

Filed under ADF

Simple way to convert af:inputText to upperCase,lowerCase,capitalize

Environment (JDeveloper 11.1.2.2.0,ADF Faces)

Sometimes you need to force the user to enter upperCase or lowerCase or capitalize letters for input text component. fortunately, there is an easy way to do this by setting contentStyle of the input text.

  • To enforce the user to enter upperCase text use this style:
<af:inputText label="Label 1" id="it1" contentStyle="text-transform:uppercase;"/>
  • To enforce the user to enter lowerCase text use this style:
<af:inputText label="Label 1" id="it1" contentStyle="text-transform:lowercase;"/>
  • To enforce the user to enter capitalize (InitCap) text use this style:
<af:inputText label="Label 1" id="it1" contentStyle="text-transform:capitalize;"/>

5 Comments

Filed under ADF