Thursday, December 22, 2011

Adding transient attribute to standard VO

OAApplicationModule am = pageContext.getApplicationModule(webBean);
OAViewObject vo=(OAViewObject)am.findViewObject("ListVO");
if(!vo.isPreparedForExecution()){
vo.executeQuery();
}

if(cvo!=null){
try{
String transientAttr=cvo.findAttributeDef("XXAttr").toString();
}catch(Exception e){
vo.addDynamicAttribute("XXAttr");
}

Debugging Techiques in OAF

Posting soon....

OAF Interview Question

Posting soon

Migrating Personalization from one instance to another

Posting soon...

OAF - Making mandatory Attachement Mandatory

Case - Need to make the Attachment Bean mandatory. Use the below line of code in PFR.

OAMessageAttachmentLinkBean oamessageattachmentlinkbean = (OAMessageAttachmentLinkBean)oawebbean.findChildRecursive("");

String attachVal = (String)oamessageattachmentlinkbean.getAttributeValue(oapagecontext.getRenderingContext(),TEXT_ATTR);

if("None".equals(attachVal))
{
throw new OAException(“Attachment mandatory”,OAException.ERROR);
}

Sunday, April 17, 2011

Add Days to Date in OAF

 
import oracle.jbo.domain.Date;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import java.text.ParseException;

String initDate =selectedRows.getAttribute("InitDate")+"";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
String tatDate=null;
try
{
c.setTime(sdf.parse(initDate));
c.add(Calendar.DATE, 1); // number of days to add
tatDate = sdf.format(c.getTime()); // dt is now the new date
System.out.println("New Date : "+tatDate);
}
catch (ParseException e)
{
throw new IllegalArgumentException("Encountered Date format error "+ e);
}

Calculate the difference between two Dates in OAF

 
Date StartDate= (Date)CurrentRow.getAttribute("StartDate");
Date CurrentDate = (Date)am.getOADBTransaction().getCurrentDBDate();
java.sql.Date sdate = (java.sql.Date) StartDate.dateValue();
java.sql.Date cdate = (java.sql.Date) CurrentDate.dateValue();
int days = daysBetween(sdate,cdate );

public int daysBetween(java.sql.Date d1, java.sql.Date d2){
return (int)( (d2.getTime() - d1.getTime()) / (1000 * 60 * 60 * 24));
}

Friday, April 8, 2011

Add New Row in Advanced Table in Editable Mode

Making the Table Rows Read-Only - Gyan

Tuesday, March 22, 2011

Key FlexField in OAF Pages

KFF in OAF Page-Gyan

Monday, March 7, 2011

Set Focus on a Bean Dynamically

In some situation you need to set the focus on particular Bean. Below is the Code for achieving the same.

import oracle.apps.fnd.framework.webui.beans.OABodyBean;
OABodyBean oabean = (OABodyBean)pageContext.getRootWebBean();
oabean.setInitialFocusId("Item_Name");

Programmatically Adding the Fire Partical Action to a Bean

In some situations where you need to add the Fire Action (Action Type) to the Bean @runtime. Below is the code to achieve the same.

 
import oracle.cabo.ui.action.FireAction;
import oracle.cabo.ui.action.FirePartialAction;
OAMessageChoiceBean mb=(OAMessageChoiceBean)webBean.findChildRecursive("BeanId");
FireAction firePartialAction = new FirePartialAction("DelAction");
mb.setAttributeValue(PRIMARY_CLIENT_ACTION_ATTR,firePartialAction);

Set the Prompt for the Bean Programmatically

There are some situation when your page contains a web bean that does not have a prompt value associated with it.
This usually get noticed, when a user enters an invalid value for the web bean, the error message that results will be malformed.

eg: Value "TestData" in "" is not a number.
 
import oracle.apps.fnd.framework.webui.beans.message.OAMessagePromptBean;
OAMessagePromptBean bean = new OAMessagePromptBean();
bean.setID("TestID");
//Replace NewPrompt with the Prompt you want
bean.setPrompt("NewPrompt");
//Replace BeanID with the Id of the bean
bean.setLabeledNodeID("BeanID");
webBean.addIndexedChild(bean);

Monday, February 21, 2011

Using Inline Custom CSS

 
import oracle.cabo.style.CSSStyle;
CSSStyle customUnCss = new CSSStyle();
customUnCss.setProperty("text-transform","uppercase");
customUnCss.setProperty("color", "#F6358A");//# -purple
OAStaticStyledTextBean staticbean = (OAStaticStyledTextBean) webBean.findChildRecursive("approvedIJPText");
if(staticbean!=null)
{
staticbean.setInlineStyle(customCss); //set custom css style
}

Sunday, February 20, 2011

Dynamically changing the Table Column Header

 
import oracle.apps.fnd.framework.webui.beans.table.OAAdvancedTableBean;
import oracle.apps.fnd.framework.webui.beans.table.OAColumnBean;
import oracle.apps.fnd.framework.webui.beans.table.OASortableHeaderBean;

OAAdvancedTableBean tableBean = (OAAdvancedTableBean)webBean.findIndexedChildRecursive("AdvTabRN");
OAColumnBean columnBean = (OAColumnBean)tableBean.findIndexedChildRecursive("empidCol");
OASortableHeaderBean colHeaderBean = (OASortableHeaderBean)columnBean.getColumnHeader();
colHeaderBean.setText("<newText>");