Sample application - CreateInsert.zip, demonstrates how to create editable table with 'create new row' functionality in ADF BC.
We will use Jobs entity, generated from standard HR schema Jobs table. When view object and application module are generated, it is time to drag and drop Jobs table in View layer. Drag and drop it as ADF Table (not read-only). When table is created, expand Operations group and select Create operation.
Drag and drop selected Create operation to the 'actions' facet of the table and create ADF Command Button. However, it is not enough just to drag and drop. Additionally, select created button with right mouse click and choose Edit Binding. In the opened dialog choose CreateInsert instead of Insert as an action for JobsView1.
Now, drag and drop Commit operation to the 'actions' facet of the table and create second ADF Command Button. Finally, we have implemented editable table with 'create new row' feature.
How to make exisiting records readonly and newly created record writable untill save.
ReplyDeleteHi,
ReplyDeleteYou must change ReadOnly property value for each af:inputText component contained in af:column. Set ReadOnly property value to - #{row.JobId != null} . This means, if row isn't empty => it will displayed as read-only. In other case, if row is empty => it will be displayed as editable.
Regards,
Andrejus
How to make the selected row editable in the table.
ReplyDeleteEditable should be inline with the table
Hi,
ReplyDelete1). Create in af:column two af:inputText components (one read-only,
second editable) for the same attribute.
2). For Edit button create ActionListener, that will store selected
row ID into managed bean atttribute
3). In managed bean create similar method:
public boolean isEnableEditing() {
FacesContext ctx = FacesContext.getCurrentInstance();
Application app = ctx.getApplication();
ValueBinding bind = app.createValueBinding("#{row.id}");
Long rowId = (Long)bind.getValue(ctx);
this.enableEditing = ids.contains(rowId); // change this
return this.enableEditing;
}
4). For editable af:inputText set #{valueHolder.enableEditing} in
Rendered property
For read-only af:inputText set #{!valueHolder.enableEditing} in
Rendered property
(valueHolder - managed bean name)
Regards,
Andrejus
Hi,
ReplyDeleteI am new to ADF EJB Toplink. I followed your instructions but was unable to commit the transaction to the Oracle database. The UI shows as updated for current transaction but the daabase4 does not get updated. How do I add the explicit commit?
Hi Pankaj,
ReplyDeleteYou can try to drag and drop Commit operation on your Save button. Also, if you are using EJB and TopLink, you can add commit method call into your EJB Session Bean method.
Regards,
Andrejus
probably because I'm a newbie on ADF (or because I'm using 11g) but I can't find the "Actions" facet on the table. I assume I should be looking at the "Structure" view in JDev. I see the af:table. All the af:columns and the "Table facets" with detailsStamp, footer and header.. But I don't see the "Actions facet". Any pointers would be greatly appreciated.. Thanks!
ReplyDeleteGary
Hi,
ReplyDeleteYes, Actions facet is not defined in 11g. But you can put buttons into header facet - it shouldn't be a problem. Since we have header facet, Actions facet is not needed.
Regards,
Andrejus
I realized I posted this to the wrong blog entry!
ReplyDeleteok, I will try that. Now if I could only get a button to actually show up!!!
Thanks!
Hi,
ReplyDeleteI have a two questions regarding adding new rows to table:
1) As you can see each time it adds the newly created row at the top of the table.
Could you please tell me how I could add it at the end of the table? By at the end I mean after all rows in the table. For now I am considering that my table would not have too many rows a few like around 20-30 rows.
2) Can I add more than one empty row? My requirement is to add three empty rows at the end of the table when the user clicks on create row.
Any help would be greatly appreciated.
Thanks
Hi,
ReplyDeleteYes for sure.
For question one you can use similar code:
BindingContainer bindings = getBindings();
DCIteratorBinding dcib = (DCIteratorBinding) bindings.get("JobsView1Iterator");
RowSetIterator iter = dcib.getRowSetIterator();
Row newRow = iter.createRow();
iter.insertRowAtRangeIndex(iter.getRangeSize() - 1, newRow);
iter.closeRowSetIterator();
For question two, I have already posted exactly similar sample:
Create multiple rows in Oracle ADF
Regards,
Andrejus
Hi Andrejus,
ReplyDeleteThank you for your prompt reply.
I have one more question regarding this.
User clicks on Add, this add's three new rows to the table. But he ends up filling only one row in the table. The other two rows are empty. Now he clicks on submit to commit the rows. I do not want to add the two empty rows, commit is happening through the Model directly. So can I write a validator on the table such that I remove the rows that are not filled by the user. Since the rows are not committed to the table how do i handle this?
-Thanks and Regards
Hi,
ReplyDeleteYou can create Action method for Commit button and in that method access Iterator. You can check rows in Iterator and remove any not needed rows.
I will post such sample in the future!
Thanks,
Andrejus
Hi,
ReplyDeleteI am using RichTable insted of CoreTable. Richtable is bound to List which contains list of object. When I remove the object from list i can the see the richTable inside backing bean is updated and row count is deceresed. But it is not getting refreshed into UI.
Regards,
Hiren
Hi Hiren,
ReplyDeleteRichTable is available in 11g, probably you are using 11g. I have sample application for CRUD operations in 11g - JDeveloper 11g - Create, Edit and Delete operations in ADF Faces af:table component. Hope it will solve your problem.
Regards,
Andrejus
Hi,
ReplyDeleteI want to display a row in a table while loading the page.
Thanks & Regards
Vimala Balan
Hi Vimala,
ReplyDeleteIt shouldn't be complex. You can just put InvokeAction in Page Definition to invoke Create action. InvokeAction should have condition to be activated on page load.
Regards,
Andrejus
Hi Andre,
ReplyDeleteThanks for your help. If you don't mine please send sample code. What are the steps to be followed in JDeveloper. Since i am new to the framework... seeking help from people like you to build my application.
Thanks & Regards
Vimalan Balan
Hi Andre,
ReplyDeleteThe below syntax given in page definition file. Actually i have master table and detail table. Header details are need to store in master and values from rows need to store in detail table. While loading the page i can show one row now but if i refresh the page it showing two rows and also if i add another row by using create and refresh again it displays 4 rows. Kindly help to solve this.
invokeAction id="createNewRequest" Binds="Create" Refresh="prepareModel"
Thanks & Regards
Vimalan Balan
Vilmalan,
ReplyDeleteYou are almost right, just little fix from me, you need to use:
invokeAction Binds="Create" id="invokeCreate" Refresh="prepareModel" RefreshCondition="${adfFacesContext.postback == false}"
I have tested, it works.
Regards,
Andrejus
Hi Andre,
ReplyDeleteOnce again thanks. I send a mail to you with screen shot and code. Its not working for me.
While page loading it displays single row but if i refreshed again means it shows single row but with navigation option in the row... previous and next.
Thanks & Regards
Vimalan Balan
Hi Andre,
ReplyDeleteIts possible for to check whether the current row is entered or not while refreshing the page or submitting the page.
Any sample code is there means please send it or post it.
Thanks & Regards
Vimalan Balan
Hi,
ReplyDeleteI will send you my updated application, with added invokeAction.
Regards,
Andrejus
How to do this with ADF Toplink ?
ReplyDeleteThanks,
Ricky
Hi Ricky,
ReplyDeleteI think it's easily possible to do the same with TopLink as well.
Regards,
Andrejus
Hi Andrejus,
ReplyDeleteI've just found out the toplink method CollectionBeanClass must be set to UpdateableCollection to show operation action in Data Control such as Create,Next,etc..
I have successfully do 'Create' button, but Commit operation is little bit different between ADF BC and Toplink. I've tried using mergeEntity/persistEntity, but still can not commit the new row to db. I've also tried to create method commitTrans in EJB Session bean method, but it's not updated to db. The code is like this :
public void commitTransaction() {
Session session = getSessionFactory().acquireSession();
UnitOfWork uow = getSessionFactory().acquireUnitOfWork(session);
uow.commit();
}
I know there must be something wrong with this code. Could you help ?
Thanks,
Ricky
Hi,
ReplyDeletei can use persistEntity and pass this value to the entity parameter:
${bindings.findAllMenuDataIter.currentRow.dataProvider}
the new row successfully inserted to database.
Try mergeEntity and also pass the same value, the row did not updated to db.
Regards,
Ricky
Hi Ricky,
ReplyDeleteI think this is correct behavior. Since mergeEntity is used to update existing object.
Regards,
Andrejus
Hi Andrejus,
ReplyDeleteI am using ADF + EJB + Toplink. How do we configure a button such that it will create a new row or update if row exists?
Hi,
ReplyDeleteYou should use mergeEntity operation.
Regards,
Andrejus
Hi
ReplyDeleteI need to create more than one row using the create Insert operation. Now I want to access the values of the newly created rows .. and insert them into some other table through the Application Module .. writing a method there where I will pass the values dynamically..
Is it possible to do that ??
Hi,
ReplyDeleteFor multiple rows check my blog post: Create multiple rows in Oracle ADF.
Regards,
Andrejus
Hi Andrejus,
ReplyDeleteWhat about inserting row that use Oracle generate sequence? since we can't just input this number. How would we configure the "Create" and "Commit" operation to work for it.
Thanks,
Minh
Hi,
ReplyDeleteIt will work automatically. Just specify DBSequence type for your attribute.
Regards,
Andrejus
Hi Anderjus,
ReplyDeletei am bharathi. i followed the above mentioned step.
i have one problem i am using LOV is one of the column in that ADF Table.
when ever i add one more row in that table it refresh so the selected LOV also refreshed so the selected value empty. it means i wand select again.
How to resolve this problem,
thanks..
Hi,
ReplyDeleteThere should not be difference for fields with LOV. May be you need to commit, before creating new rows.
Andrejus
Hi,
ReplyDeleteI have a requirement to make first two columns of the newly added rows invisible or disabled.Can u please suggest how to proceed with it? I'm new to ADF so request you to kindly provide me with some explaination in detail..
Hi,
ReplyDeleteI dragged VO of a table on JSF page. I want one column of it to be in the form of a drop down. When I converted it from input text to selectManyCheckbox,I got error message and when i deleted the column with input texts which i got by dragging the VO and dropped a selectManyCheckbox component from component palette then the value selected in this drop down was not recognized by the application. It's taking null. Can you please help me in resolving either of the below:
1) After dropping VO if i convert one column's inputText to selectManyCheckbox then how to overcome the error and insert the selected value in that paricular column of the table?
OR
2)If I delete one column's inputText and drag and drop selectManyCheckbox from component palette then how do i get the value selected in this dropdown?
When Navigating from one Jsf page to another Jsf its giving error as JBO-27014.(SummaryId attribute is required)JDeveloper 10g(10.1.3.3.0) Version.
ReplyDeleteBut SummaryId is there is First Page EO attribute its giving error in Second Jsf Page.
Can Any One, Plz Help us in this regard.....................
hi,im havina a small query in ADF. i'm having 2 jspx pages and i want to navigate from one page to another. for that i have given this
ReplyDelete(return "To SkillsInformation";)
To SkillsInformation is the name of the navigation link for other page. but after pressing save and proceed button in which i have written this return statement, it is navigating into the second jspx page and while giving data for second page it's showing error as
Error:
JBO-27014: Attribute SummaryId in TempSkillsEO is required
SummaryId is the primary key in the first jspx page's EO. but we are not passing any SummaryId into second jspx page.
can u plz give solution to it.
why i can't create new row, when i create table without generate from data control (only drag some field i need it into table column)??????
ReplyDeletethx
I am trying jdeveloper 10g and I used the createInsert as you have demonstrated here to insert a new row in a table.
ReplyDeleteThe table I have created has rows with fields with selection from a dynamic LOV (List Of Value).
When the new row is inserted in the table the existed rows are re-displayed with empty all the fields that are LOV.
How I can fix that?
Hi,
ReplyDeleteHow can I use Create with Parameters operations in JDeveloper 11g, can you give me an simple example or some tips.
Thank you!
Regards,
Eleven.Xu
Hi Andrew,
ReplyDeleteI am new to ADF and i have a question about the invokeAction. Currently i am developing some sample application and i am stretching my head to resolve the issue. Hope you will throw some idea to help me on this.
I have a taskflow and a view. In the backing bean i have the init() method and i am invoking that when the taskflow is initialized. However when i refer the one ADF component inside the method then i am getting null because the component is not being initialized based on the JSF phases. Now my question is i would like to execute on method when the page is being loaded. Any other way that i can use the InvokeAction to do that. please not i am not using DataControl for the model. Using standard EJBs.
Please help me on this.
-thiva
Hi,
ReplyDeleteYou can try to use Method Call before navigating to your page, however it still may not work if you are referencing ADF Component.
As second choice, you can declare beforePhase method on af:document tag, means method will be invoked on page load.
With invokeAction you can invoke only methods declared in Page Definition.
Regards,
Andrej
Thanks for the quick response. I tried out this and it is working for view and document. How about for the dialog, popup and Boundedtaskflow which doesn't have the af:view or af:docuemnt.
ReplyDelete- thiva
Thanks for the quick response. I tried out this and it is working for view and document. How about for the dialog, popup and Boundedtaskflow which doesn't have the af:view or af:docuemnt.
ReplyDelete- thiva
How to set cursor focus on the first column of a newly added row in a table?
ReplyDeleteHi,
ReplyDeleteYou can try to use DisplayRow = selected property on af:table.
Regards,
Andrejus
HI Andrejus,
ReplyDeleteI am struck at point:-
I want to write code (Enable/Disable and assignment of value to input text etc).
I have gone through Jdeveloper forum and try to implement onpageload() through phaselister but it is not working with. The onpageload()not being called when in open that page.
I need your help in this regard.
Can upload/post any example regarding this issue
I will be thankfull this favour.
Regard
M Niaz
Hi Andrejus,
ReplyDeleteI have dragged the view object as a ADF Table and created 3 buttons for CreateInsert, delete and commit functionality for the same.
When i click on createInsert it create's a new row in the table. What should i do if i want to delete that new empty row created. ( it gives me error sayin the Primary key fields needs to be entered and doesn't let me delete the empty row usind the delete button)
Please help.
Regards,
Aparna
Hi,
ReplyDeleteYou need to use Rollback operation for this, not Delete.
Andrejus
Is there any functions or procedure like the NEXT_RECORD in Oracle Forms Developer?This use for the detail record operation to create multi rows and bar scanners input. in your examples it needs to push button to create or insert record.
ReplyDeleteIm new with this jdeveloper and no knowledge about it ,html or java(etc.). but im trying this adf and im interested with it...
Currently using Forms 10g on AS10g
sorry for my english...
Tnx...
Is there any functions or procedure like the NEXT_RECORD in Oracle Forms Developer?This use for the detail record operation to create multi rows and bar scanners input. in your examples it needs to push button to create or insert record.
ReplyDeleteIm new with this jdeveloper and no knowledge about it ,html or java(etc.). but im trying this adf and im interested with it...
Hi,
ReplyDeleteIn my jspx page i have a button,textfield and a table. when user enters a number, say '2' and clicks on the create button 2 rows have to be created in the table provided a unique id(which is combination of char and numbers)be inserted in table and displayed in the table. So when button clicked generating unique id, inserting it to table and displaying it to table has to be done. How can i do that.
Hi Andrejus,
ReplyDeleteThis is really a good post. I have one basic doubt here please clarify.
Consider I have two text boxes in my UI and two buttons save and cancel. What operations I should use here. My main doubt here is can i use commit alone without create/createInsert.???
Yes of course, why not?
ReplyDeleteAndrejus
Hi Andrejus,
ReplyDeleteCan you provide one quick code snippet for the below scenario.
Consider I have two text boxes and a check box in my UI. and there is no data in the tables. so my landing page should contain two textboxes and one check box, one save button and one cancel. So how can I achieve this. As per my undestanding to insert records into database we should first click either create/createInsert buttons and I dont want to use this. One more thing I observed is if there is no data in the tables. The UI Components are shown in read only mode? why is this behavior? How can i made them editable? Please clarify with some example/code and steps. I am struggling for this past one week.
May be this post will help you: http://andrejusb.blogspot.com/2011/11/oracle-adf-11g-table-insert-with-empty.html
ReplyDeleteAndrejus
Hi,
ReplyDeleteNo that solution doesn't work for me. In my case consider i have a table with a primary key, a varchar2(15), char(1) columns. and there is no data in that table. now i want to insert data into this table from the ADF page. my adf page contains one textbox bound to that varchar2(15) column and one checkbox bound to char(1) and one save button. now there is no create or createinsert buttons on my page. so how can i do this? i observed if there is no data in the table the textbox is not coming ine thr ui and checkbox is shown in readonly mode. please provide some code snippet. i m struggling for past 15 days. thanks in advance.
And how you want to insert data without Create data, there must be some other event?
ReplyDeleteAndrejus
Yes Andre, I have a BTF and in that i have a method call. So can i do something with this?? I am thiking like at the time of calling this method it should verify whetehr data is there in the table or not if there is no data then it has to show in create page(with empty fields) and if data osi there then the adf page has to show that existing data. Please provide some solution for this.
ReplyDeleteHi Andre,
ReplyDeleteCould you please respond to my previous post.
Yes, you can implement this easily with Router activity and calling different Method Actions from TF.
ReplyDeleteAndrejus
Hi Andrejus,
ReplyDeleteThanks for the post. But in one of the comments the code you provided for adding at the end of the row
iter.insertRowAtRangeIndex(iter.getRangeSize() - 1, newRow)
This will throw error for out of range, so rather it should insert at the index after last row
iter.insertRowAtRangeIndex(iter.getRangeIndexOf(lastRow) +1, newRow);
Thanks for update.
ReplyDeleteAndrejus
Hi,
ReplyDeleteI have two col1,col2. col2 is unique.
I want to insert record if it's new(col1 value is new or doesnot exist) and override col2 if the col1 value is already exist,programmatically.
Hi Andrejus,
ReplyDeleteThank you so much for the post. It helps newbies like to learn a lot from such posts.I have a question regarding similar implementation.
Requirement:
Page to be loaded with an empty form and a table with values. On filling in the empty form and clicking save, the row should be committed to the database and added to the table as well, but the focus on the table has to be on the newly created row. There is only one button to save as on saving the form, the form gets erased and a new form appears and the saved row is populated in the table.
Approach Followed: In my taskflow, I made createInsert as a default view for the iterator I needed and then directed to my view with form and table. I dragged and dropped commit button as save below the form and it works fine.
Question: My question here is I want to programatically commit the page because before committing I want to do some other logic in the page
I used the following
BindingContainer dc = (BindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
OperationBinding operbind= dc.getOperationBinding("Commit");
operbind.execute();
On doing programatically I only see the row populating but its not getting saved. Could you please help me to programatically save on createInsert
hi , i want to create the same table but jobID wont be shown on table but when i insert the row to db, i will get jobid from session, is it possible to do it in adf?
ReplyDeletethanks for help.
Just check if your page def holds commit operation in Binding section. If no, Click on Binding tab of your page , in Bindings column , click on Add , choose a Action , click OK , Select The appropriate DataControl and Select Commit as Operation.
ReplyDeleteI have created editable table but one of my column is LOV field for which i have used 'SelectOneChoice' but wen i call 'CreateWithParams' method to get new editable row I m not getting the LOV field, filed is not at all available not even empty. Plz suggest
ReplyDelete