While coaching ADF developers, I have noticed people are not using standard ADF BC Data Control operation - CreateWithParams. Instead of simply using this standard operation to assign default values on create, sophisticated algorithms are created to provide default values for the new row initialization. This happens mainly, because standard operation CreateWithParams is a bit not intuitive to use, its why developers sometimes avoid using it. In this simple blog, I will describe how you can apply CreateWithParams operation in two easy steps.
Download sample application - ADFRegionCommunication.zip.
CreateWithParams operation allows us to define parameter to assign it to the new row for some specific attribute, for example here we have parameter for JobId declared along with CreateWithParams operation:
Its very important to mention, that when you will define CreateWithParams operation by yourself, wizard will not allow you to add parameters - parameters table will be empty (its what is confusing most of the developers). So, in order to add parameter, you should right click on already defined CreateWithParams operation and choose Insert Inside - NamedData:
When NamedData will be added, manually provide attribute name, which you want to be initialized (JobId in my example). Also provide attribute type and of course initialization value:
Download sample application - ADFRegionCommunication.zip.
CreateWithParams operation allows us to define parameter to assign it to the new row for some specific attribute, for example here we have parameter for JobId declared along with CreateWithParams operation:
Its very important to mention, that when you will define CreateWithParams operation by yourself, wizard will not allow you to add parameters - parameters table will be empty (its what is confusing most of the developers). So, in order to add parameter, you should right click on already defined CreateWithParams operation and choose Insert Inside - NamedData:
When NamedData will be added, manually provide attribute name, which you want to be initialized (JobId in my example). Also provide attribute type and of course initialization value:
Dear Andrejus,
ReplyDeleteI couldn't understand where you give the JobId the value .
You made executewithparam but I don't know where to put my value to the variable you created.
I think the project needs more explanation.
Did you read all article? Its described right there in the middle about NamedData. I will not copy paste it here again:)
ReplyDeleteEnjoy !
Andrejus
Hi Andrejus,
ReplyDeleteCan we create EntityObjects that can combine multiple table, eg: Order and Order Items. So when I call a method like getOrder(orderID) the I get the order with all the order items in a Single Object as a response.
Also, can we combine or perform joins and then create VO of these, as my requirements is to create Webservice operations to perform CRUD operations. But these operations can internally do CRUD on multiple tables. I am looking some thing like Hibernate framework.
Yes, you need to define Associations between Entities. Then you can join multiple Entities into one VO, to create join.
ReplyDeleteOne Entity should be based on one table, as it is primary concept of Entity.
Andrejus
Thanks Andrejus,
ReplyDeleteDo you have any blogs on how this is done, or any document to which I can refer.
Thanks
Ashwin
Yes, ADF Developer Guide section, is the best: http://download.oracle.com/docs/cd/E17904_01/web.1111/b31974/bcquerying.htm#CEGEGHFB
ReplyDeleteAndrejus
Thanks for the trick. It works perfectly.
ReplyDeleteHi,
ReplyDeleteThanks for the good information.
When I use this "CreateWithParams" is there a way I can make some of the fields "readonly".
i.e. when user clicks this button, it needs to make one of the attributes/field "readonly"?
Can you tell how please?
Hi,
ReplyDeleteYou can use isAttributeUpdateable method inside EO Impl class.
Andrejus
Hi Andrejus,
ReplyDeleteThis worked great when we have one Iterator Binding.How can we achieve the copy functionality when we have more than one Iterator Binding to deal with as if I wish to duplicate the master as well as detail grids?
Hi,
ReplyDeleteYou can define another CreateWithParams action in PageDef, just change it name to something else, not to conflict with already added action.
Andrejus
Hi,
ReplyDeleteI have created createWithParameters and it works fine for Strings and Numbers.
When I add in Date I get this error:
JBO-25009: Cannot create an object of type:oracle.jbo.domain.Date from type:java.lang.String with value:17/10/2011
In page Def:
ApprovedDt is 'Date' in VO and EO.
Why am I getting this error?
Thanks,
Jenny
Hi Andrejus,
ReplyDeleteWhen I drag and drop CreateWithParams operation in task flow . It throws null pointer exception error.
Please help what's going wrong?
Thanks.
Great Job thank you Andrejus
ReplyDeleteregards