RE: Item Selector button is disabled

thumbnail
Massimo Bevilacqua, modified 5 Years ago. Regular Member Posts: 210 Join Date: 12/27/16 Recent Posts
I have followed the tutorial in this page about Item Selector
https://portal.liferay.dev/docs/7-0/tutorials/-/knowledge_base/t/selecting-entities-using-the-item-selector

After some adjustment it works, but now I have a problem, the "add" button inside the Item selector is disabled and the code inside the "selectedItemChange" function is never called.

I just need to select a file and the get the name(or title) of the file.
Someone knows how to do it?
thumbnail
Andrew Jardine, modified 5 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Hey Massimo,

I don't have a lot of experience with the item selector stuff (just haven't gotten around to it yet) but I am happy to troubleshoot with you. Can you share some code? and maybe shed some light on some of the "adjustments" you made to make it work? 

My first thought as to why the button is disabled is, of course, permissions related -- but that's just a stab in the dark.
thumbnail
Massimo Bevilacqua, modified 5 Years ago. Regular Member Posts: 210 Join Date: 12/27/16 Recent Posts
Hi Andrew,
thank for the reply.

In th end I have found the problem.

In the tutorial there is in the java part:

PortletURL itemSelectorURL = _itemSelector.getItemSelectorURL(
    requestBackedPortletURLFactory, "sampleTestSelectItem",
    imageItemSelectorCriterion);


and in the JSP code:

<aui:script use="liferay-item-selector-dialog">

    $('#<portlet:namespace />chooseImage').on(
        'click', 
        function(event) {
            var itemSelectorDialog = new A.LiferayItemSelectorDialog(  
                {
                    eventName: 'ItemSelectedEventName',
                    on: {...</aui:script>


The event name must be the same written in the java code, in this example "sampleTestSelectItem" and not "ItemSelectedEventName". Using the same name in both it works.

I always found Liferay tutorials and documentation very confusing