Skip to main content

Specifying Converter for a Dynamic UI Component


The following code snippet illustrates the API usage for setting JSF converter for a UI component added at runtime.
 RichInputDate inputDate1 = new RichInputDate();  
 Application application= FacesContext.getCurrentInstance().getApplication();  
 DateTimeConverter dateTimeConverter= (DateTimeConverter) application.createConverter("javax.faces.DateTime");  
 dateTimeConverter.setPattern("yyyy dd mm");  
 inputDate1.setConverter(dateTimeConverter);  
Tag doc  for af:inputDate says that -
Developers can programmatically attach a converter. That converter should be obtained by Application.createConverter(), rather than simply calling new DateTimeConverter(). Otherwise, some functionality will be missing, e.g. client conversion and validation, and the date picker will only display as an input field without the date-time popup (the popup relies on the client conversion and validation support)

Comments

pavan123 said…
Hi Jobinesh

I am using Jdev 11.1.2.1.0, the use case is, I have af:inputtext on UI in a panelform , whose datatype in DB is Varchar2(10) , this is a phone number field. The user will enter a 10-digit number 1234567890 and then it should be displayed in US number format as (123)-456-7890. But in DB it has to be stored as 1234567890. Can you help me in this regard. Detailed explanation is need and appreciated.
pavan123 said…
Hi Jobinesh

I am using Jdev 11.1.2.1.0, the use case is, I have af:inputtext on UI in a panelform , whose datatype in DB is Varchar2(10) , this is a phone number field. The user will enter a 10-digit number 1234567890 and then it should be displayed in US number format as (123)-456-7890. But in DB it has to be stored as 1234567890. Can you help me in this regard. Detailed explanation is need and appreciated.
Jobinesh said…
Pavan
One option is build custom JSF converter. More details here http://docs.oracle.com/cd/E24382_01/web.1112/e16181/af_validate.htm#ADFUI360
VenkY said…
Thanks for the Post...
got the exact code i looking for

Popular posts from this blog

Happy New Year 2018 !

We can't go back and change the beginning, but we always can start where we are and change the ending. Believe in yourself and you will be unstoppable!

Wishing you and your family a very happy new year 2018 !!!

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…