ADF – Defaulting value in poplist

Normally, we have a display value and code value for poplists. We show the display value to the user and store the code value in the database. Take a scenario where we have a model driven poplist where the values are populated from a VO. To achieve this, we have to create a transient attribute for display_value to which the list of values is attached, and return value is populated in the database attribute.
Now lets say we need to show a default value in the poplist. defaulting the database field in create method of entity will not default the value in display_value. so this post shows how to default the value in the display_value transient attribute and the database attribute from the base VORowImpl.
Ex: ClStatus is the EO based attribute in which code should be defaulted as ‘PENDING’
ClStatusMeaing is the transient display_value attribute in which corresponding meaning should be populated from the lov vo query.
Code to be written in the getter of the transient attribute:

public String getClStatusMeaning() {
String val = (String) getAttributeInternal(CLSTATUSMEANING);
String defaultStatus = "PENDING";
if(val == null){
Row[] rows = getStatusesLovVO1().getFilteredRows("LookupCode", defaultStatus);
StatusesLovVORowImpl row = (StatusesLovVORowImpl)rows[0];
if(row != null){
val = row.getMeaning();
setClStatus(defaultStatus);
}
}
return val;
}

Advertisements
This entry was posted in ADF. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s