Normally, if we update an attribute in a View row, we can easily see the updated value in the Entity row as changes are propagated down the hierarchy.
My question is if we instead update an attribute on the Entity level, is there a way that we can get the new value on a current View row of a View object that was built using that Entity.
If you update an attribute on EO level, it will automatically update the VO attribute as well. It goes both ways.
Seeing you are asking this makes me think you tried it and it didn’t look like working. If that’s the case, you are probably having a Partial Refresh problem in your screen. You can try using a partialTrigger.
Related
We're trying to implement a very basic functionality in ADF 11g using Jdev(11.1.1.7). We have one table in database which is exposed to the UI layer using ADF BC.
The requirement is to update a table when user selects one of the row. It will open a popup and then user can update the value in that dialog box. This works well but along with the current row, ADF framework is also updating the first row with the previous value of the update.
To update a row, we're using the standard commit button from the data control and then overidiing the DoDml method in EO to update additional fields.
Can someone share the details why this happening with each update and any solution for this?
Thanks,
LG
First, remove the selectedRowKey value from the table properties otherwise this will always select first row.
After the commit refresh the page or relevant component to load updated data to UI.
If you are updating additional fields using doDML make sure to commit the data and refresh UI to load updated data.
Commit is transaction level, if the Status of EO row is changed that row will participate in transaction. Either you need to change the status of other row to un-modify or you can override beforeCommit in VOImpl .
Thank you,
TR
How to update the view with the model.fetch(), i.e when i fetch the model, the view shouldn't be destroyed or re-rendered. It should just update the new model into view with reseting the previous model.
this.model.fetch({success: this.render.bind(this)});
This code is re-rendering my view..How can i just update the view with new model
Thanks.
There are multiple ways of updating the view based on your need.
If the view is fairly simple, and all that is needed is to automatically update the view on model's fetch, rendering the view again is the simplest(Backbone's sync event on the model can be used, and model events can be handled declaratively using Marionette View's modelEvents hash -http://marionettejs.com/docs/marionette.view.html#viewmodelevents-and-viewcollectionevents)
modelEvents: {'sync': 'render'}
If you have few model attributes that change in a complex view, you could directly update the dom elements via jquery by listening to change events on the model attributes:
modelEvents: {'change:name':'nameChanged'},
nameChanged: function(model, value){ this.$('#name').val(value);}
If Two way data binding between view and model is needed, frameworks like Backbone.stickit can be used to this purpose - https://github.com/NYTimes/backbone.stickit#usage
Whenever you establish a double binding with your model attributes to the templates, your views need to be rendered again to show the changes. So, you can't avoid rendering to show the updated status of your model.
But what I would suggest you to do is to divide your view into subviews. Since, you are using marionette, you can create a main layout which contains all the regions and for each small region, you can define a view .
For example , suppose I have a basic form with my name, current time and age . All of these variables are stored in a model . So, you have a scenario where your name and age hardly changes but the current time is changing every millisecond causing your whole view to re-render which is bad in terms of performance as well as to the eyes.
So, in order to solve the above scenario, if you could create a separate view for the current-time element, you can render is separately and other elements don't need to be rendered again and again. You can always define a separate view for a single button element if you think that its functionality can be abstracted.
Showing an example will likely make more sense than trying to explain this. Please reference this http://plnkr.co/edit/ipGYEX?p=preview as it ALMOST does exactly what I need.
In the example, click Add to create a new select menu and choose an option. This should add it to the parent form. Currently I'm handling this aspect with an $emit. The core problem is that I can't find a way to assign $index to each select. I'd like to attach it to the model name in order to make each one unique. However, simply doing something like ng-model="selectNum{{$index}} causes an error when passed through attrs.ngModel. As is, the ngModel is repeated for each dropdown that's added and thus, every time the form gets overwritten. I WANT to add each select as a unique object to the form - and update that specific instance should the associated select change.
Can anyone provide some insight on how to either attach the $index or perhaps another way of updating the form?
Not a direct answer to getting the values into the form object, but here's an option similar to something I'm doing for a very similar situation:
http://plnkr.co/edit/uEHFWgRQ9fP2gpeWuE5y?p=preview
Basically storing the values within the elements of the array being repeated on, then I use that object from the model for a post to the server.
I have an interesting situation. Working on an 11.1.1.3 ADF Application.
I have an editable table, which uses an LOV. The respective LOV has a maintenance page, where we populate a database table with data that the LOV uses.
If i'm inserting new records into the LOV Database Table, the corresponding LOV does not get those changes. However, if there is an UPDATE of existing records, it seems to work ok.
It appears the iterator is not updating. Because if i start up a new application session in a new browser window, i'll see the new changes.
The LOV doesn't have it's own iterator in the Page Bindings (Its using a View Accessor in my view object), so i'm not sure how to tell the iterator to refresh or executeQuery()...
Thank you!
Right now, my only solution is this. I don't like it, but it works...
Exposed View Row Impl class, and included accessors on my Editable ADF Table's View Object. This way i have programmatic access to my accessors that run the LOV.
Then i located my view accessor, getter method. And told it to re-execute the query. Worked like a charm:
public RowSet getAllSmsModules() {
RowSet rs = (RowSet)getAttributeInternal(SMSMODULESALL);
rs.executeQuery();
return rs;
//return (RowSet)getAttributeInternal(ALLSMSMODULES);
}
I have following requirement.
Display data in a table
Clicking on checkbox filter out currently displayed rows by some condition
Clicking on checkbox once again return data appearance to it's previous state
To achieve this I've ovverided method rowQualifies in my ViewObject which is simple SQL based view object to apply my custom filter logic.
When user clicks on checkbox I refresh view object data to apply filter
viewObject.setDoFiltering(true);
viewObject.setQueryMode(ViewObject.QUERY_MODE_SCAN_VIEW_ROWS);
viewObject.executeQuery();
It works perfectly, data set updates without interacting with database and my custom filter logic applies as well.
But when I need to cancel filter it wouldn't work because iterator doesn't contain anymore previous rows, and I can only load them from database but it means that I can lose my changes already made to view object rows.
So, when I do
viewObject.setDoFiltering(false);
viewObject.setQueryMode(ViewObject.QUERY_MODE_SCAN_VIEW_ROWS);
viewObject.executeQuery();
It will return me those rows that were displayed previous time.
If I do
viewObject.setDoFiltering(true);
viewObject.setQueryMode(ViewObject.QUERY_MODE_SCAN_DATABASE_TABLES);
viewObject.executeQuery();
It will return me all rows, but I will lost my changes already made to view object rows.
My questions is how to avoid it? Maybe there is another way of doing this? Maybe it is possible to do something with RichTable to tell it how to filter rows in memory.
Any advices are warmly appricated!
I believe this can be done using ViewCriteria, to filter means to apply a ViewCriteria, and then disable it to view all your data