Wednesday, January 23, 2013

Immediately Removing New Row Without Validation in ADF

Once new row is inserted but not yet saved and if validation rules are defined for the attributes - it may cause problems removing this new row (let's say user changes his mind and decides to remove unwanted row). Of course user can invoke Rollback, but this is not what is always desired. User should be able to remove row with one single click - by pressing Delete button. And this is really easy to achieve in ADF, but not always obvious. You need to set Immediate = true as property for Delete button, it will call then Delete operation ignoring any validations for the current row.

Here you can download working sample application - NewRowRemoveApp.zip.

I will describe first how it works by default. User inserts new record and without providing all required data decides to remove this row by pressing Delete button. Submit happens and ADF brings all failed validation messages - this is not what user expects when simply trying to remove row:


Situation will change with Immediate = true property for Delete button on ADF UI - this allows to skip validation invocation and call Delete operation quietly:


Test again with Immediate = true. Insert new record, try to commit or move to another record to force validation messages:


Press Delete button - problematic record will be removed instantly without reporting validation errors on Delete:

12 comments:

Muhammad Nasir said...

Very Useful Info. Thanks!

Cosmin Vacaroiu said...

this is pure JSF :)

Andrej Baranovskij said...

This shows that ADF is purely standard framework ;)

Andrejus

Anonymous said...

Hi Andrejus,
I've made a delete with an immediate = true. I insert a row in a table (without commiting), then I delete it, then when I insert a new row, the new row has the values of the previous rows displayed (while when I put system.out.println on the getter and setter of the attribures of the EO, the values are null, but the values displayed in my UI are not null).

Can you please enlighten me?

Anonymous said...

My case is:
instead of table, I use form view.
When I delete new row, I'm expecting the next available row shows up in the form.
But after delete, the form is not populated with existing value. Any solution for this?

thanks

Rajesh said...

Hi Andrejus,

Even I have the same issue as the above anonymous user posted on Sep 4

When I keep immediate = 'false' for delete button I have to manually enter all the values in order to delete row(Since I have required fields). But when I create a new row in table all values are defaulted to null

When I keep immediate='true' for delete button the row is removed with out entering all values. But when I create new row the previously entered values are displayed in newly created row. I want user to be displayed a new row with all null values.

Please help me how to solve this issue. I am using JDev 11.1.1.5


Thanks,
Rajesh.

Andrej Baranovskij said...

Ok, I will test it and post update here.

Andrejus

Andrej Baranovskij said...

This sample is created for JDEV 11g R2 (11.1.2.4.0), I tested your steps - is not reproduced and working fine. I will test the same later in 11.1.1.5

Andrejus

Shahzad Ahmed Khan said...

Hello Andrejus,
I have set immediate = true but it still asking for required values?
Any idea

Andrej Baranovskij said...

Does it work in my sample app?

Andrejus

Sampada said...

I don't have property action delivery on my button..in ADF 11.1.2.4 and even my problem exists..record cannot be deleted..plz help me for solution..

Andrej Baranovskij said...

If you see old data, when inserting new row - call ResetUtils.reset method to reset UI state after delete was invoked - http://docs.oracle.com/html/E10684_08/oracle/adf/view/rich/util/ResetUtils.html

Andrejus