X

Best Practices from Oracle Development's A‑Team

Autocomplete for metadata in WebCenter Content

Introduction

When it comes to user experience, filling in metadata when submitting content is not the most enjoyable task.  But I think most agree how useful metadata becomes when it comes to finding content.  So making that experience better and easier should always be a goal.

One technique that has been around for a while and is more and more prevalent is the autocomplete (aka type-ahead).  Autocomplete is when you are typing in an input field and suggested choices are offered to you based on the characters you have typed.  It can make offer those choices either based on a pre-defined library or based on users' past values.  This allows you to keep the metadata field very fluid (not a strict option  list), but also maintain some consistency among values entered.  This is perfect for fields such as 'Keywords' or 'Tags'.

Main Article

So let's look at how we can provide that type of functionality to WebCenter Content metadata fields.

Typically in those types of fields, there is often more then one value entered.  If you look at how WebCenter Content stores those values, it's done as comma separated values stored within a single table cell.

mult-select storage

So if the goal is to provide a set of suggested values, it must pull them from multiple values in a cell from multiple rows. This provides a bit of a challenge. But with some creative SQL, it's possible to extract those values separately and organize them into their own rows of data in the result set.  Once we have the data in this format, the rest is fairly straightforward to deal with.

Below is a sample SQL query to get us the data in that format:

select distinct initcap(lower(trim(substr(xKeywords, instr(trim(xKeywords),',',1,rr.r)+1,  instr(trim(xKeywords),',',1,rr.r+1)-instr(trim(xKeywords),',',1,rr.r)-1 )))) xKeywords  from  (select ','||xKeywords||',' xKeywords, length(xKeywords)-length(replace(xKeywords,',',''))+1 cnt  from DocMeta ) DocMeta,  (select rownum r  from all_objects  where rownum <= 50) rr  where rr.r <= DocMeta.cnt  order by 1;

Now when we run the query against those multivalue metadata fields, we get the data back in separate rows:

Keywords Field

The rest of the work is all done through the UI.  In my example, I found that the jQuery UI Autocomplete widget provided a great sample to work with.   So then it's a matter of querying the data, creating the result set in JSON format for the widget, and then targeting the .autocomplete function to the metadata field.

Now when a user is checking in or updating a content item, then can begin to see a list of suggested values based on what has been entered before:

Autocomplete

And when the user is searching, they can see the values that have been used that should result in a hit.

Autocomplete

I've packaged my sample as a component if you'd like to try it yourself.  Please see the readme.txt for configuration details.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha

Recent Content