简体   繁体   中英

How to make a LOV in Oracle ADF that also returns a static value?

Say I want to have a lov of colors. Red, Blue Green. I want an LOV that retrieves those values from a database but on top of that I want to add one more value "All". So the LOV could be a list of someone's potential favorite color and by default the "All" option is displayed in the LOV. A user can choose any color or maybe decide to revert to the 'ALL" option.

Is it possible to add this static value to an LOV that retrieves values via a db? I know you can just create a static LOV but the point is we need to retrieve the latest colors or whatever value is in the db if it ever grows.

Edit: JDeveloper 12c (12.1.3.0.0)

If the 'all' option is valid, you should add it into the DB, like the other colors. If you don't want to put 'all' into the DB, you can use SQL and create the 'all' option as a static result before the actual query to the table using a union SQL statement.

One other way to archive this is to add the 'all' option to the items list in a bean, like it's shown here https://community.oracle.com/tech/developers/discussion/616712/adf-faces-how-to-add-static-option-to-dynamic-lov

You still have to think about what should happen if the user selects 'all' from the list. How does the UI handle this?

I think you should insert "All" value to table in database. The table should contain "ORDER_COLOR" column. We will prepare data some thing like: ("All", 999999) ("RED",1) ("BLUE, 2) ("GREEN",3) ("NEWEST_COLOR",4)

In ViewObject query. You can order by ORDER_COLUMN desc. The ALL will on the top and next one is NEWEST_COLOR

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM