Skip to main content

Create row on a clickToEdit table

Generally developers use 'createInsert' operations associated with the iterator binding to insert a new row. Works perfectly! However, when you use the same technique on a clickToEdit table to create new rows, all goes well, but the newly create record does not become the 'active row'. So the end user can by pass the validation and can create multiple records without key in the mandatory fields for the newly created ones, by clicking the 'Create' button multiple times.

A possible work around solution for this scenario is to customize the record creation, and programatically set the ActiveRowKey, as shown below.

    public void createAction(ActionEvent actevnt) {
        BindingContext bc = BindingContext.getCurrent();
        DCBindingContainer dcb =
        OperationBinding op = dcb.getOperationBinding("createDept");
        Row row = (Row)op.execute();
        if (op.getErrors().size() == 0) {
            ArrayList lst = new ArrayList(1);
You can download the sample workspace from here.
[Runs with Oracle JDeveloper 11g R1 PS2 + HR Schema]


Jordi said…
Hi, we are trying to use this workaround, but we cannot find the setActiveRowKey() method for the RichTable class! Although it is in the class' API, it does not compile in our JDeveloper (version

Do you know why is this happening? I think we are using the same version as you. Thank you very much
Jordi said…
I'm Jordi again. We've find that the setActiveRowKey() method is new from JDeveloper, so we can't use it.

Do you know any other workaround? Thanks
Jobinesh said…
yes its available with PS2 release( Sorry, I'm not aware of any work around for the same, to use with earlier versions.
Anonymous said…
Great Post...
Anonymous said…
Hi Jobinesh,

I have a case where I have a adf cliktoedit table in a popup (table in a jsff fragement in a bounded taskflow which is invoked as a popup). In the popup i do createinsert rows.
however, the next time i open the popup the empty rows are still existent. How do remove those empty rows from the table on popup open ?

Jobinesh said…
I didn't quite understand the question fully. If you use ADF BC, createInsert will add new entry in EO cache, so what you are seeing is expected. An example may help me to understand it better.That said,however you can use popupfetchListener for perfroming all initialization logic(keep the content delivery as lazyUncached)
Anonymous said…
Hi Jobinesh,

I have a condition where my adf table based on a VO (filtered rows for a particular location). However, there might be a case where the user creates a new row and wants to assign a location (and modify) the row in the table. But this row may not be unique and may be already present in the db. That means i create the row with parameters, and try to commit, if it already exists i update else insert. however, now i get uniqueness constraint since its creating new row. Do you know how we can create a vo row that will update if exists else create ?

otherwise i can fetch the row independently and put it up in the iterator if it already exists. but i guess i will face the uniquenss error

Anooj said…
Hi Jobinesh,
I have tried your approach. But the problem I'm facing is that a new row is getting created, but it does not appear on the af:table. When I click the save button, I get a error messages about empty attribute values.
Jobinesh said…
Check partialTrigger is set properly for the table comp. Not able to think of any other reason
Anooj said…
Hi Jobinesh,
I had checked everthing. The af:table is a part of jsff inside a bounded taskflow. For the taskflow, I had made taskflow transaction as 'Use same transaction if possible'.

When I changed tasflow transaction to use '', the new row gets inserted with the new row being visible in af:table.

Is it correct or should I try something else.
Jobinesh said…
If your task flow is not invoked by a caller which has initiated a transaction, then ideally you may need to start a transaction from the taskflow if it involves data update. So it looks OK for me.
Ankur Pradhan said…
Hi Jobinesh,

I used popupFetchListener to invoke CreateInsert, but I see that empty row is still getting inserted on my table.

Also i used PopupCanceledListener to Rollback transaction in case Esc key or (X) button, but my Rollback is not getting called.

Any idea why so strange behaviour.

Elias Ghanem said…
Hi Jobinesh,
I have a similar problem.
I'm using Jdev I have a simple table with a createInsert operation button.
When i click the button, a new row is created and appear in the table.
The problem is that if, after creation of a new row a change the selected row and then re-select the newly created row i have the following error in the console:
ADFv: No row found for rowKey: [oracle.jbo.Key[1 ], oracle.jbo.Key[312 ]]. (where 312 for ex is the key of the newly added row).
The problem doesn't appear if the editingMode is edit all. it only appears if it is click to edit.
Any hint?

Popular posts from this blog

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…