Search This Blog

Friday, September 30, 2011

loading and passing parameters to messages using resource bundle in ADF page


Load a property file using message resource bundle feature inbuilt within the core tag .

Typical example would be to refer to a message value(Login Message), labels etc..

Approach 1 :

f:loadBundle basename="XX_GLOBAL" var="globalres"
Sample as how to refer to the value in a property file using the core tag is
af:outputText value="#{globalres.loginmessage}"

Calling a property file using resource bundle from Backing bean.

public class MyUtilBean {
public String getMessage(String loginmessage) {
FacesContext context = FacesContext.getCurrentInstance();
ResourceBundle bundle = context.getApplication().getMessageBundle();
ResourceBundle resourceBundle = ResourceBundle.getBundle(bundle,Locale.ENGLISH);
String text = resourceBundle.getString(loginmessage);
return text;
}
}

 

Approach 2 :

String resoureBundle= "view.MyBundle";
ResourceBundle resources= BundleFactory.getBundle(resoureBundle);
String msg=null;
if(resources != null)
{
       msg= resources.getString("loginmessage");
}

Approach 3 :

FacesContext fc = FacesContext.getCurrentInstance();
ResourceBundle resources= fc.getApplication().getResourceBundle(fc,"MyBundle");
bundle.getString("loginmessage");


Approach 4 :  (Passing Parameters to the Resource Bundle entires)
 
oracle.jbo.common.StringManager.getString ("view.MyBundle", "loginmessage","No Match Found", new String[] {Param1Value, Param2Value .......});

Thursday, September 29, 2011

OAF - Calling Database sequence

Calling a Database sequence.
Traditional way of calling a sequence was to create a View object with a "select sequence.nextval as seqvalue from dual" and call something like below.

OAViewObject vo = (OAViewObject)am.findViewObject("sequencename");
OARow row = (OARow) vo.first();
Number seqvalue = row.getAttribute("seqvalue"));

But instead oracle provides a direct API to get the value of the sequence and can be used as below.

// Calling from within an Application Module.
OADBTransaction trx = getOADBTransaction();
Number seqnum = transaction.getSequenceValue("sequencename");

//Calling from controller
OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean);
OADBTransaction transaction = (OADBTransaction)am.getOADBTransaction();
Number seqvalue= transaction.getSequenceValue("sequencename");

OAF - String to SQL Date

Convert the String object to java.sql.Date object using stringToDate() function from oracle.apps.fnd.framework.OANLSServices class like below.

java.sql.Date getClientSysdate(){
OADBTransaction trx =
(OADBTransaction)getApplicationModule().getTransaction();
OANLSServices nls = trx.getOANLSServices();
oracle.jbo.domain.Date serverDate = trx.getCurrentDBDate();

java.util.Date javaClientDate = nls.getUserDate(serverDate);
long longDate = javaClientDate.getTime();
return new java.sql.Date(longDate);
}

Wednesday, August 4, 2010

Tips to refine ADF code.

Tips to refine ADF code for better performance.

1. Page definition actions to be removed rather execute the VO in the backing bean.

2. Refresh condition for the iterators to be set to false in the Page definition. Make it to true in the backing bean only when that iterator is executed.

3. Get the AM instance from the VO rather than using createRootApplicationModule() method.

4. Use generic method for iterator execution.

5. Remove unnecessary bindings from pagedef, backing bean.

Samples to follow...


Sunday, March 14, 2010

OAF - Create VO on FLY.

String s = "select parameter_id from ap_expense_report_params_all erp where erp.expense_type_code = :1";

ViewObject viewobject = getDBTransaction().createViewObjectFromQueryStmt(s); viewobject.setWhereClauseParam(0, "ROUNDING");

viewobject.executeQuery();

OAViewRowImpl row = (OAViewRowImpl)viewobject.first();

if(row == null)

mRoundingParameterId = null;

else

mRoundingParameterId = (Number)row.getAttribute(0);

viewobject.remove();

OAF - How to add a new VO into a existing AM

If you have only to add a column to a VO you don't need to extend the AM.
To do this, you must create a new VO (e.g. XXReqSupplierVO) which extends the standard VO (e.g. ReqSupplierVO) substitute the standard VO with your new VO.


1. Right click on ur project file (xxx.jdr)


2. Edit Business Components Project...


3.Substitutions, Select the standard VO in the left panel and your VO in the right panel then click on Add Button


4. import the substitution on the server (running jpximport utility on your xxx.jpx file)


5. Bounce the OC4J(Apache) server


6. Ur new item on ReqSupplierLovRN page must refer to standard VO name (ReqSupplierVO), not to the personalized one. As you have imported the substitution on the server, at runtime when you refer to ReqSupplierVO the system, instead, use the extended GECMReqSupplierVO, so you can use your new column.
You don't have to create a new AM.My problem was different, because I needed to create a completely new VO, not to extend and existing one, so I had to add a new VO to the AM and that is why I would extend it.As it's not actually possibile I had to create a new page and to use directly my AM instead of the standard one. But this is not your case, I think.
In order to import them you have to right click on your project name and to choose "Import Business Components". Then you must select the server.xml file that you should find in the same directory (oracle.apps.icx.por.schema.server).


Monday, March 8, 2010

OAF - Remove Personalizations

ACTION PLAN===========
1. Login to application

2. Select Responsibility Functional Administrator

3. Click Personalization Tab ( Upper Right)

4. For Application , Enter the following: Self-Service Web Applications

5. Click on the Personalized Checkbox

6. Click Go

7. Remove or De-activate your personalization by selecting the personalization level at which you made a particular persanolization

Check the following tables before and after removing the Personalizations.
1. JDR_COMPONENTS

2. JDR_ATTRIBUTES

3. JDR_ATTRIBUTES_TRANS

4. JDR_PATHS