Tuesday, January 16, 2007

ADF: Oracle Form like overflow in ADF Faces + current row highlighting

This is step-by-step instruction how to create Oracle Forms like overflow layout in ADF Faces and how to highlight selected row in data table.



1. In your adf faces page change form tag from h:form to af:form to have simple item ids.

2. Create overflow.js javascript file with this method:

function selectRow(itemClicked, tableId, radioId) {
var rowId = itemClicked.id.substring(itemClicked.id.indexOf(":") + 1,
itemClicked.id.lastIndexOf(":"));
radioItem = document.getElementById(tableId+":"+rowId+":"+radioId);
if (!radioItem.checked) {
radioItem.click();
}
}

3. Attach the javascript to your page with:

<script src="overflow.js" type="text/javascript"> </script>

Change path of js file as needed.
Note: there must be a space character between <script> tag and enclosing </script> tag otherwise the generated html code will not be correct.

4. Drop your data source on the page as an adf table and choose desired columns. Drop the same data source as an adf form under the table and choose items you want to see in overflowed block.

5. Enable select one selection in the table

6. Give the table id = tbl, selection radio button (tableSelectOne component) id = selRow

7. Enable Auto Submit for the tableSelectOne radio button

8. Set overflowed panelForm partialTriggers to table id "tbl"


9. Add these properties to each table item:

styleClass="#{row.rowKeyStr == bindings.YourIterator.currentRowKeyString ?
'currentRow' : ''}"
onfocus="selectRow(this, 'tbl', 'selRow')"

where "YourIterator" is name of your data source iterator and "currentRow" is name of css skin selector for highlighed items. The selector could look like:
.currentRow {
background-color: rgb(255,255,181);
}

Now you can run the page.
Mouse click on any table item will change current row and the row will be highlighed. Overflowed block will always contain values from the current row.

You can temporarily download zipped JDeveloper 10.1.3.1 demo applicaton of adf overflow from here.
It is based on emp and dept tables from scott db schema.

Rado

11 comments:

Unknown said...

hi,
you have mentioned at a place that we have to apply the style class on each table Item.. what do you mean by table item, do you mean to say on the whole table or on the column or on the output text in the table..
do reply soon
I am confused

RadoK said...

Hi shirzad,
I'm sorry for so late answer. I mean each adf input, output component in each column (af:outputtext, af:inputtext, ...). In this version of adf faces there is no way to use style for whole row (ok, there probably is using javascript and DOM but it is more complicated)

Makrand Pare said...

Hi Radok,

I tried to use the CSS part in my code for a Text Field in Table Column. However even after putting explicitly the name of CSS block, I couldn't see the color of my Textfield getting changed. Do you have any idea why?

Joyce said...

Hi,
I am wondering that is it possible to highlight selected rows in mulitple selection.
I tried to change tableSelectOne to tableSelectMany, but I got the same behavior as using tableSelectOne. The reason is we set "autoSubmit" to true. Do you have any ideas to make it possible?

Thanks

RadoK said...

Hi Makrand,
see my second post with a new type of row highlighting. It works for input texts also.

Rado

RadoK said...

Hi Joyce,
I will try to make multiselect highlighting work in my second blog post. Do you also use overflow in your application or you just want to highlight selected rows?

Rado

Haripriya VenkataSubramaniyan said...

Hi,
Could you please guide me in building oracle forms using ADF? Is it possible with jdev 10g?

RadoK said...

Hi,
my blog post was about how in JDeveloper create functionality similar to Oracle Forms.
In JDeveloper you can only create java application that looks similar and has similar behaviour as oracle forms does but it is no more oracle forms application. Forms are able to run in web browser and also adf<--forms integration is possible (see http://www.oracle.com/technology/pub/articles/wilfred-adf-forms.html) . Anyway these technologies are different.

Do you really need forms in JDeveloper or "something" with functionality of forms?

Anonymous said...

hi,
i 'd like to know if this could work without using radio button, i m' trying but no result came up


Mrwan

RadoK said...

I don't think so as radio button is used for row selection. Maybe you can hide the radio button with javascript/css. I cannot confirm it will work as I didn't try it.

zealmall.com said...

so many nike shox shox 2009,nike shox 2010 for you,we have many
nike shox monster shoes,

nike shox r3 shoes,
shor r4 shoes,
shor r5 shoes