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.
[Runs with Oracle JDeveloper 11g R1 PS2 + HR Schema]
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 =
(DCBindingContainer)bc.getCurrentBindingsEntry();
OperationBinding op = dcb.getOperationBinding("createDept");
Row row = (Row)op.execute();
if (op.getErrors().size() == 0) {
ArrayList lst = new ArrayList(1);
lst.add(row.getKey());
getDataTable().setActiveRowKey(lst);
}
}
You can download the sample workspace from here.[Runs with Oracle JDeveloper 11g R1 PS2 + HR Schema]
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 11.1.1.2.0).
ReplyDeleteDo you know why is this happening? I think we are using the same version as you. Thank you very much
I'm Jordi again. We've find that the setActiveRowKey() method is new from JDeveloper 11.1.1.3, so we can't use it.
ReplyDeleteDo you know any other workaround? Thanks
Jordi,
ReplyDeleteyes its available with PS2 release(11.1.1.3.0). Sorry, I'm not aware of any work around for the same, to use with earlier versions.
Great Post...
ReplyDeleteHi Jobinesh,
ReplyDeleteI 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 ?
Thanks,
Sunil
Sunil,
ReplyDeleteI 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)
Hi Jobinesh,
ReplyDeleteI 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
thanks
sunil
Hi Jobinesh,
ReplyDeleteI 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.
Anooj
ReplyDeleteCheck partialTrigger is set properly for the table comp. Not able to think of any other reason
Hi Jobinesh,
ReplyDeleteI 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.
Anooj
ReplyDeleteIf 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.
Hi Jobinesh,
ReplyDeleteI 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.
Thanks
Ankur
Hi Jobinesh,
ReplyDeleteI have a similar problem.
I'm using Jdev 11.1.2.3.0. 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?