cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How can I override EditorConfigurator or DefaultModelValueHandler

pratik_a_soni
Participant
0 Likes
1,111

I want to fetch some more reference rows to be displayed on the PCM Backoffice editorArea. It is of type reference so either I can override EditorConfigurator.updateObjectsReferencedByEditor() or DefaultModelValueHandler.getSimpleValue().

The problem is, I'm not sure how can I override any of them. Anyone has attempted this earlier?

Accepted Solutions (1)

Accepted Solutions (1)

former_member625836
Active Contributor
0 Likes

Hi ,

In my opinion it is not the way you should go then. Please consider creating a new editor that extends com.hybris.cockpitng.editor.defaultmultireferenceeditor.DefaultMultiReferenceEditor. There you have a method #render which is called every time new product is selected for display. In this method you can easily load whatever you need to load an manipulate the data as you wish. It may be possible that you would also have to create a new layout that extends com.hybris.cockpitng.editor.commonreferenceeditor.ReferenceEditorLayout and is created in #createReferenceLayout method of editor (it is called every time new item is selected for display). Then you can assign this editor to particular attribute in particular view.

Please also bear in mind a difference between editor and layout: - editor is responsible for interpreting the data from model and updating it (I guess that it should not update model with inherited model) - layout is responsible for displaying data provided by editor (you could try to add some elements here).

Hope it helps, Jacek

pratik_a_soni
Participant
0 Likes

Thanks Jacek for the suggestion.

I overridden the DefaultExtendedMultiReferenceEditor and overloaded the setInitialValue method. There I invoked my business logic to fetch the data and store certain info in the session map, so that later while rendering the list row I can highlight where this value is coming from.

I added one additional column in the listView and wrote a custom renderer to render that column. In that custom renderer I read this session attribute value and shown the icons appropriately. As I was reading each row I deleted the values from session attribute to remove the footprint.

I made sure that the key does not interfere with other objects.

Thanks for the suggestion.

I did investigate ReferenceEditorLayout to do the same but was not reaching to any good point. Maybe I'll try that again later at some point.

Let me know if you've any further suggestion or if my approach is wrong.

Regards Pratik

former_member625836
Active Contributor
0 Likes

Hi,

It all depends on whether you call removeSelectedObject, addSelectedObject, refreshObjects or changeSelectedObject with inherited items. If so then they may be assigned directly to displayed item and it may not be expected behaviour of application. Please make sure that com.hybris.cockpitng.editors.EditorListener#onValueChanged is never called with improper list of references.

Cheers, Jacek

Answers (1)

Answers (1)

former_member625836
Active Contributor
0 Likes

Hi ,

Wouldn't referenceModelProperties bean override enough?

Cheers, Jacek

pratik_a_soni
Participant
0 Likes

Thanks Jacek, you always cite good direction.

I tried with your approach. This is the method that I've overridden collectReferencedObjects There are two problems with this:

  1. I didn't find a direct way to fetch the current product. As there can be zero values for the current product but I want to fetch more results from the variant above current product.

  2. I want this to be performed only if the user is on PCM Backoffice. Which mean I want to add some check for authority. Is there any way to check that programmatically?

I really appreciate your inputs. Also to give some background, we want to implement data inheritance. We've product setup in multiple levels using Product and Variant Product. I want to fetch the data from all the levels and run some merge logic.

We currently do it in Cockpit, but since we've to migrate to PCM Backoffice.

Thanks Pratik