What is the best way to implement default values stored in a DB table?
253131Jul 27 2006 — edited Aug 10 2006[JHeadstart 10.1.3 build 78]
[JDeveloper 10.1.3 SU4]
We are struggling on how to best implement default values that are stored in a DB table. What we have is a database table with (CODE_TYPE, TABLE_NAME, COLUMN_NAME, DEFAULT_VALUE) as columns. This way the application administrator can administer default values himself/herself. Now we need to find the best way to set these table supplied default values in new rows. Globally we are aware of two ways:
- override create() method on VO
- probably create a View Object on top of the database table with default values (we are capable of transposing the table and return exactly one row with a column for each default value) and use JHeadstarts item property 'Default Value'.
We prefer the latter, since this is more declarative, however we struggle with the EL expression needed to indicate the default value.
If we have a VO named "DefaultValues" with a SELECT on a view on top of our database table (transposed) returning exactly one row, let us say:
SELECT orglanguage, orgtype, orgstatus [...]
FROM v_default_values
--> returning exactly one row
and we want an EL expression on an item that needs the value from orglanguage. What will the EL expression be? Something like:
#{data.DefaultValuesPageDef.currentrow.orglanguage.inputValue}? We tried several things but they do not work. A static default value works, but every EL expression so far does not. We know that using "data" can be dangerous, but thought JHeadstart takes care of preparing the other Page Definitions, so it might be possible when you use JHeadstart.
Or is overriding the create() method the preferred way? Or do we have to look at a Managed Bean for our default values that we refer to from EL (let us say MyAppDefaultValuesBean) and in that case: how do you associate a Managed Bean with a VO?
Any help would be appreciated. Apart from these default values, things are going rather well in this first J2EE/JHS project for us!
Toine