I have an issues concerning the custom auto handlers in ipojo. I have created an handler (say Handler-Auto), I want this handler to be auto attached to a POJO component instances (say Comp-1) without touching the metadata of POJO components.
To achieve this, we need to set the "org.apache.felix.ipojo.handler.auto.primitive" variable in the system property with the list of handlers as specified in the below link:
https://issues.apache.org/jira/browse/FELIX-2594?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel#issue-tabs
The problem is, when I do like this, my handler (Handler-Auto) is attached to all the components or instances that are created or deployed over the system. To intercept methods or fields from a particular component we need to add filter at the handler. But its too late to add filter after attaching handlers with all unnecessary stuffs.
Instead of attaching the handler to all the components, Is there anyway that, this handler (Handler-Auto) can me made to be attached to a specific components or instances ? as per the user wish.
It would be great if we have this feature and it ll become very dynamic.
Please help if there is any other way to do this or what could be the solution to achieve this ??
thanks for your help in advance!
Thanks,
Sadish
Related
I'm trying to edit a Master-Detail View multiple times in Catel.
My question is, if there is no common way in catel to handle a Master-Detail-View and multiple editions using the SaveViewModelAsync and CancelViewModelAsync methods?
The workflow works when my Master-ListItem is no UserControl with it's own ViewModel and when I change the selected Master-ListItem after save or cancel, so that a new ViewModel will be created. But I don't want to null or change the selection after a save/cancel. Also I have maybe to create a UserControl + ViewModel for the Master-ListItems.
Restrictions of the question:
I have got the information from Geert van Horrik from the discussion of his answer, that
multiple edit cycles are not supported directly
one Model should only be accesd by one ViewModel
Problem:
I can use the the SaveViewModelAsync and CancelViewModelAsync only once. After that, the ViewModels which are alive
will get no updates from the Model
don't create a BackUp from the Data, so that the changes can be reverted again
Code to Reproduce:
I have created a WPF Project, where I tested this all.
Possible solution:
I could use the EditableObjectHelper and handle this by myself
I have to instantiate the VewModel again, after the save or cancel, like it happends on a selection change in my Example Code
Restricion of the solution:
If I use a specialized UserControl for the ListItems of the Master-View, 2 ViewModels are looking on 1 Model. After the SaveViewModelAsync the ViewModel doesn't get any Notifications of the Model. So I would have to instantiate this ViewModel again too. But I would Breake the 1-1 relation of the ViewModel-Model.
My conclusion:
It seems, that I have to instantiate all these ViweModels and handle this workflow all by myself. It seems, that the ViewModelLifetimeManagement.PartlyManual (CloseViewModelOnUnloaded is Obsolete) doesn't work here. On selection change, always a new ViewModel will be created, the old one will probably just not be closed.
I don't want to misuse the framework. Maybe I have missed something. I hope somebody can help me or give me a tip, how to handle this.
Catel calls Save / Cancel as soon as the view model get's unloaded. If you want to do "intermediate" saves without changing the data model, you can:
Save the master list which will save the dirty models (you can directly modify the models from within your vm's)
Create a custom command (SaveData) that you can run from an explicit button (or input gesture binding) to save the data without calling SaveAsync on the vm
After the answer of Geert van Horrik, I currently ended up , don't using the SaveViewModelAsync and CancelViewModelAsync methods and handle the save and cancel by my own, so that the notification will not breake. I'm using the GetChildViewModels() method on the ViewModelBase and the EditableObjectHelper.CancelEditObject(Model);
Our Orchard application displays two of all notifications that are added to the notification service. So far we have traced the problem and know what is causing it, but are looking for a solution other than the obvious, for reasons I shall now elaborate.
So we are using a number of themes to render our Orchard based application. Within our layout, we have a Razor call to draw a header bar that displays a set of information about the user that is logged in.
#Html.Action("OutOfGameHeader", "Options", new { area = "Area.area.Location.Common" })
This action calls the OnResultExecuting() method in Orchard.UI.Notify.NotifyFilter which (among other things) populates the Messages Zone with the current set of notifications. When we make the call the render the Messages Zone, this same method runs again and the notifications are added to the Zone's shape again resulting in duplicate notification being displayed when the Zone is actually drawn.
Can anyone think of a solution that meets the following criteria:
Drawing the header without calling #Html.Action() to avoid OnResultExecuting() being triggered the first time.
Without creating a new Widget in a new Zone as this would involve us changing the manifest for dozens of existing themes to include it.
We also found this just below the point in the code where the notifications are added to the Zone, so if anyone knows anything more about it, that would be helpful too.
//todo: (heskew) probably need to keep duplicate messages from being pushed into the zone like the previous behavior
//baseViewModel.Messages = baseViewModel.Messages == null ? messageEntries .Messages.Union(messageEntries).ToList();
//baseViewModel.Zones.AddRenderPartial("content:before", "Messages", baseViewModel.Messages);
Any thoughts greatly appreciated.
Avoid Html.Action. This runs through the whole lifecycle as if this was a new request. That you think you need it is often a sign that you need to refactor and extract that logic that you want to re-use out of your controller. In Orchard, it's also better to use dynamic shapes.
We have a dialog inheriting MvxDialogViewController containing two Sections - TheRadios and TheList.
In response to the user changing the radio within TheRadios, we repopulate TheList (in the view model).
How can we bind a Section of a MvxDialogViewController to a dynamic list?
Looking through all the mvvmcross samples I couldn't find an example of this being done. I considered inserting a MvxActionBasedTableViewSource into the relevant Section's TableView but the property is null.
If you do want to bind a list within a Dialog section to a list, then I believe this extension may help you - https://github.com/asednev/MvvmCross.AlexeysExtensions
I'm afraid it is for vNext rather than v3 currently, but I think it should port very easily - I think the only changes needed would be just a few namespace changes (if you do port it, then please send them a pull request with the changes)
Alternatively
it is open source, so it may give you alternative ideas
you could consider using a custom or manual binding to INotifyPropertyChanged in order to achieve the table changes you are looking to achieve
I can't seem to get a clear answer for this: when you change a transient property, and then call save, should the NSManagedObjectContextDidSaveNotification be triggered? In my notification listener, how can I filter out these notifications that are coming from changes in transient properties?
Here's what I'm trying to do: I want to load up a list of contacts in the main thread, and when it's done, I want to read the images in a background thread from the address book and attach them to the contacts. This works fine on the face of it: after loading from the Contacts entity, I use a dispatch queue to loop through all the contacts, find their image in the Address Book, and save them in Contact's "contactImage" property (which is transient). The dispatch queue then successfully reloads the tableview (on the main thread) and the images show up next to the contacts.
The problem is that if I do anything to the contact that invokes a "save" on even ONE of the managed objects (for e.g. I delete one of the contacts), the NSManagedObjectContextDidSaveNotification is invoked for ALL the contacts. I've found that this is because the contactImage property was changed before ... commenting that the "self.contactImage = img;" line makes the issue go away. This is surprising to me, since I would have thought that the save notification would only be called for non-transient properties.
Can anyone confirm if this is expected behavior? Or am I doing something wrong? If it's expected, how do you filter out the updates to transient properties in the NSManagedObjectContextDidSaveNotification listener? I need to do some post-processing in the listener, and I don' want to do it needlessly for transient property updates. I've checked the changedValues dictionary on the NSManagedObject, but it seems to show empty inside the listener (since only transient properties changed, I'm guessing).
Thanks.
Yesterday,
Transient properties have one key characteristic -- they are managed. You can easily add ivars that are not managed to any NSManagedObject. If you do so, they are not subject to -save: notifications.
A related question: Why are you using a transient ivar? They have some specialized uses; primarily, they are used to trigger property updates throughout the model; i.e. the behavior you are seeing.
A second related question: why are you background fetching all of the images instead of lazy loading them from the Address Book? This looks like a case of premature optimization to me.
Andrew
I've being trying to solve this problem but I couldn't figure it out yet. In my layout have a listview with its custom adapter. Inside each view I have many objects stored in a static class called ViewHolder. One is a gallery with another custom adapter.
My problem is that after I get an onActivityResult on my Activity. I need to send a notifyDataSetChanged() to my gallery adapter. If I do:
((BaseAdapter)list.getAdapter()).notifyDataSetChanged();
All the items inside the adapter are refreshed except the ones that have their own custom adapter.
Now I thought maybe I thought maybe there is a way to override onNotifyDataSetChanged() or something like that to send the notification from within my ListAdapter once I notify it. But I couldn't find something like this, is there a way to do this?
I've also noticed that if I try to do:
((BaseAdapter)ListAdapter.ViewHolder.this.gallery.getAdapter()).notifyDataSetChanged();
It sais: "No enclosing instance of ListAdapter.ViewHolder is accesible in scope" Is there a way to make it accessible?
Or another way to accomplish what I'm trying to do?
Thanks in advance
I feel ashamed... It seemed that I forgot to renew a few variables for it to work right...
So the conclusion is the adapter inside the adapter gets updated if you call:
.notifyDataSetChanged();
You just have to do it right