ADF Access page binding in View Object's Bind Variables - oracle-adf

I have a binding on an ADF page, called eventID. I have a View Object which I'm trying to select from the database based on the value of this eventID. I have the View Object with a View Criteria, and it uses a "bind variables" defined in the View Object to select based on a value. I need to make the value of the "bound variable" equal to one of the page's bindings, I think I need to do this based on an expression that resolves to the page's binding "eventID", how do I do this?
I have tried to make the value of the Bind Variable equal to the expression #{bindings.eventID} but this throws a Groovy exception when I click on "Test":

In similar cases I am not using declarative approach. You can execute a method that will execute the query with the bind variable's value. The following code is a sample query for default HR schema that comes with Oracle database:
int empID=123; // sample employee id
//declares application module and view object
AppModuleImpl appMod = (AppModuleImpl)(JSFUtils.getApplicationModule("AppModuleDataControl"));
ViewObject employeesVO = appMod.findViewObject("EmployeeView");
// start building your query
employeesVO.setWhereClause(null);
employeesVO.setWhereClauseParams(null);
employeesVO.setWhereClause("EMPLOYEE_ID = :1");
employeesVO.setWhereClauseParam(0, empID);
employeesVO.executeQuery();
If you still interested in the declarative way, checks this link. It may help you:
enter link description here

Related

How to save child properties?

Breeze & Angular & MV*
I get an invoice object and expand it's necessary properties: Customer, Details, etc.
To access detail properties is easy, invoice.detail[n].property. And saving changes to existing properties (1 - n) is also easy. In my UI, I simply loop through my object vm.invoice.details to get & display all existing details, bind them to inputs, edit at will, call saveChanges(), done!
(keep in mind, in this UI, I need to complete the following too....)
Now, I have blank inputs for a new detail I need to insert.
However, I need to insert a new detail into the existing array of invoice details.
For example: invoice #5 has 3 details (detail[0], detail[1], detail[2]). I need to insert into this existing invoice, detail[3], and call saveChanges()
I've tried to call the manger.createEntity('invoice') but it complains about FK constraints. I know you can pass values as a second argument in createEntity('obj', newvalues)...but is that the correct and only method?
Seems like this should all be much easier but, well, I am at a loss so, please help where you can. TIA!
Take a look at the DocCode sample which has tests for all kinds of scenarios including this one.
Perhaps the following provides the insight you're looking for:
function addNewDetail() {
var newDetail = manager.createEntity('Detail', {
invoice: vm.currentInvoice,
... other initial values
});
// the newDetail will show up automatically if the view is bound to vm.details
}
Notice that I'm initializing the parent invoice navigation property. Alternatively, I could just set the Detail entity's FK property inside the initializer:
...
invoiceId: vm.currentInvoice.id,
...
Either way, Breeze will add the new detail to the details collection of the currentInvoice.
Your question spoke in terms of inserting the new Detail. There is no need to insert the new Detail manually and you can't manage the sort order of the vm.currentInvoice.details property any way.
Breeze has no notion of sort order for collection navigation properties.
If you need to display the details in a particular order you could add a sorting filter to your angular binding to vm.currentInvoice.details.
Make sure you have correct EntityName, because sometimes creating entity is a not as simple as it seems.Before working with entities see
http://www.getbreezenow.com/documentation/creating-entities
I will suggest you to look ur metadata file, go to last line of your file, you can see the field named "entitySet"
"entitySet":{"name":"Entity_Name","entityType":"Self.Entity_Name"}
check the entityName here i took as "Entity_Name" and then try to create the entity and use this name
manger.createEntity('Entity_Name');

AngularJS - After Filtering The Model Isn't Updated

I just wanted to see if anyone has had experience with the issue I having. I am currently populating a select element from a restful web service using the ng-options feature and assigning it to my model with ng-model. I have also applied a filter to this select that changes the list based on the value from another select element. Everything works as intended from the display side. If I change the master select element and it filters the second select to not include the currently selected item, the display shows correctly and displays 'please select'. So this looks great and works as I intended but when this scenario happens the underlying model isn't updated and still has the invalid option stored in it. If I pass the model back to the server for further processing, I am getting values that might not be valid.
Does anyone have any ideas on how to have selected that filter one another also update the underlying model ?
I appreciate any ideas.

Why using the this.$(selector).method() syntax with backbone?

I have seen this bunch of code in a tutorial:
var searchTerm = this.$('#searchTerm').val().trim();
I would like to understand the utility of the this. in front of the selector, it's the first time i see that.
In a Backbone.View, this.$ gives a scoped version of jQuery. It is in fact equivalent to using this.$el.find which is in turn equivalent to using $(this.el).find.
Anyhow, the reason it is a good idea to use it is that it will only access html elements from within the view's element/rendered template. Thus, you don't have to worry about the rest of the html page and you will always select the element you expect to.
Imagine that you have a view that spawns sub-views and that each of these have an editable field. If you don't use the scoped version of jQuery to get the right editable field, you will have to give a unique id to each of these html elements to make sure you will select the right one when retrieving it's content. On the other hand, if you use the scoped version, you will just have to give this editable field a class attribute and selecting this class will give you a unique element, the right one.
This is the same query as this.$el.find('#searchTerm').val().trim();
You haven't given any context to that code, but assuming it's a method inside a View, this refers to the View object.
this.$ is a shortcut to access jQuery from the View object, and is equivalent to the method this.$el.find.

Why do i receive an object with null properties when returning from a domain service call in a SV app? i use LinqToEntitiesDomainService

i am making a call from SV app to a domain service and waiting to receive IQueryable. In my model i have an one to one relationship with the object UserSession. So in the linq query i am telling that i need an eager loading on UserSession.
return (from u in this.ObjectContext.Users.Include("UserSession") where u.UserId == pUserID
&& u.UserSession != null select u).First<User>();
inside the method in the service if i am accessing myUser.UserSession i have the UserSession object but when i receive this object on the Silverlight the myUser.UserSession is null. Why ? It is normal to have this behavior ? I am thinking that is not; because why else i would use relations in EF if i can not use them. On bad workaround is to make 2 calls, one for the user and one for the user session.
Can somebody give me a hint? thank you.
Finaly i found an answer thanks to this blog:
http://madsdevblog.blogspot.com/2011/02/eager-loading-ef4-entities-with-ria.html.
But for short i was trying to eager load the the User object and in order to do that in EF4 you must do these steps:
Step I. Disable eager loading
"1. Double click on your .edmx file in the solution explorer
2. Right click anywhere in the white space and click "Properties"
3. In the properties window, set "LazyLoadingEnabled" to false.
You will then see that in the generated file, the following line will be added:
this.ContextOptions.LazyLoadingEnabled = false;
"
Step II. Use Include in the linq query (step which i already do)
Step III. Add the [Include] attribute to the navigation properties
"1. Locate the section where Navigation Properties are set
2. Add [Include] as an attribute beneath the [DataMember()] attribute
3. Add using System.ServiceModel.DomainServices.Server; to the using section in the template.
4. Save and run the template.
"

Silverlight 4 Domain Data Source Filter Descriptor on nested property

I have an object model where I'm checking a filter value of nested child property e.g.
Order -> Customer
And Customer has a property e.g. Name = "Joe Bloggs"
My domain service returns IQueryable<Order>. My domain data source is bound to this (and in turn my Grid is bound to the domain data source), and I have a filter descriptor set as something like this:
<ria:FilterDescriptor Operator="Contains" Value="{Binding Text, ElementName=txtCustomerName}" PropertyPath="Customer.Name" IgnoredValue=""/>
This all works great, except the relationship between Order and Customer is optional i.e. an Order may not have a Customer and therefore the Customer navigation property may be null. In such a situation, when running the query, the domain data source throws a null reference exception - presumably because it's trying to traverse the Customer and get the Name value when of course the Customer is null.
Has anyone come up with a good solution to this problem?
I ended up solving this by using the MVVM equivalent to the DomainDataSource - the DomainCollectionView and its associated classes. With this, you have more control of your query composition and I therefore made my query do a null check on the Customer property before evaluation the Name property on it.

Resources