RE: RE: Item Selector PopUp Not Showing the Add/ Cancel Buttons in Lr 7.4GA93

Jamie Sammons, modified 1 Year ago. New Member Posts: 12 Join Date: 4/18/24 Recent Posts

Hi Eveyone!

Recently we have migrated our code from Liferay 7.0 GA7 to 7.4-GA93. We used LiferayItemSelectorDialog in LR7.0 and that's not working in 7.4 and got error "A.LiferayItemSelectorDialog is not a constructor". We have refered stackoverflow, they mentioned the solution to build "Item Selector" and we have implemented. Please find below url which we refered.

Uncaught TypeError: A.LiferayItemSelectorDialog is not a constructor - Liferay Portal 7.4 GA 105 - Stack Overflow
Implementing an Item Selector - Liferay Learn

Issue:

After deployment the popup came successfully, but the "Add" and "Cancel" button are not coming in bottom of the popup.

Do I need to anything in the searchcontainer to show the buttons ?

Could you please help us to resolve the issue ?

thumbnail
Olaf Kock, modified 1 Year ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts

Due to the links, we know the documentation that you followed. But we don't know what you actually did.

In order to help identifying issues in your code, it would help to be able to look at your code. Ideally a minimal version that just shows the problem.

Olaf Kock, modified 1 Year ago. New Member Posts: 12 Join Date: 4/18/24 Recent Posts

Thanks Olaf for your quick response.

Here I'm attaching my code.

update.jsp:

<aui:button href="javascript:;" id="addThemenUsers" value="add-users" name="add-users" />

var addThemenUsersButton = document.getElementById('<portlet:namespace />addThemenUsers');
    addThemenUsersButton.addEventListener(
        'click',
        function(event) {
            Liferay.Util.openSelectionModal(
                {
                    eventName: '<portlet:namespace />selectUsers',
                    on: {
                        selectedItemChange: function(event) {
                            var selectedItem = event.newVal;
                            console.log(selectedItem);
                            if (selectedItem) {
                                form.fm('themenverantwortlicheAddUserIds').val(selectedItem);
                                submitForm(form, '${themenassignuser}');
                            }
                        }
                    },
                    title: '<liferay-ui:message arguments="${userGroup.name}" key="add-users-to-x" />',
                    url: '${selectUsersURL}'
                }
            );
        }
    );

<portlet:renderURL var="selectUsersURL" windowState="<%=LiferayWindowState.POP_UP.toString()%>">
        <portlet:param name="mvcPath" value="/select_user_group_users.jsp" />
        <portlet:param name="userGroupId" value="${userGroup.userGroupId}" />
    </portlet:renderURL>

select_user_group_users.jsp:

<%
long userGroupId = ParamUtil.getLong(request, "userGroupId");

UserGroup userGroup = UserGroupServiceUtil.fetchUserGroup(userGroupId);

String displayStyle = ParamUtil.getString(request, "displayStyle", "list");

String eventName = ParamUtil.getString(request, "eventName", liferayPortletResponse.getNamespace() + "selectUsers");

PortletURL portletURL = renderResponse.createRenderURL();
portletURL.setParameter("mvcPath", "/select_user_group_users.jsp");
portletURL.setParameter("userGroupId", String.valueOf(userGroup.getUserGroupId()));
portletURL.setParameter("eventName", eventName);

PortletURL searchURL = PortletURLUtil.clone(portletURL, renderResponse);

UserSearch userSearchContainer = new UserSearch(renderRequest, searchURL);
UserSearchTerms searchTerms = (UserSearchTerms) userSearchContainer.getSearchTerms();

long[] selectedThemenverantwortliche = {};
Serializable themenverantwortliche = userGroup.getExpandoBridge().getAttribute(UserGroupPortletKeys.CUSTOM_ATTR_THEMENVERANTWORTLICHE);
if (themenverantwortliche != null) {
    selectedThemenverantwortliche = (long[]) themenverantwortliche;
}

RowChecker rowChecker = new SetUserUserGroupChecker(renderResponse, selectedThemenverantwortliche);

LinkedHashMap<String, Object> userParams = new LinkedHashMap<String, Object>();

%>
<aui:nav-bar cssClass="collapse-basic-search" markupView="lexicon">
    <aui:nav cssClass="navbar-nav">
        <aui:nav-item label="users" selected="<%= true %>" />
    </aui:nav>
    
    <aui:nav-bar-search>
        <aui:form action="<%= portletURL.toString() %>" name="searchFm">
            <liferay-ui:input-search
                markupView="lexicon"
            />
        </aui:form>
    </aui:nav-bar-search>
</aui:nav-bar>

<aui:form cssClass="container-fluid-1280" method="post" name="fm">
    <liferay-ui:search-container
        id="users"
        rowChecker="<%= rowChecker %>"
        searchContainer="<%= userSearchContainer %>">
        
        <liferay-ui:search-container-results>
            <%
                if (searchTerms.isAdvancedSearch()) {
                    total = UserLocalServiceUtil.searchCount(company.getCompanyId(), searchTerms.getFirstName(), searchTerms.getMiddleName(), searchTerms.getLastName(), searchTerms.getScreenName(), searchTerms.getEmailAddress(), searchTerms.getStatus(), userParams, searchTerms.isAndOperator());
                    results = UserLocalServiceUtil.search(company.getCompanyId(), searchTerms.getFirstName(), searchTerms.getMiddleName(), searchTerms.getLastName(), searchTerms.getScreenName(), searchTerms.getEmailAddress(), searchTerms.getStatus(), userParams, searchTerms.isAndOperator(), searchContainer.getStart(), searchContainer.getEnd(), searchContainer.getOrderByComparator());
                }
                else {
                    total = UserLocalServiceUtil.searchCount(company.getCompanyId(), searchTerms.getKeywords(), searchTerms.getStatus(), userParams);
                    searchContainer.setTotalVar(String.valueOf(total));
                    results = UserLocalServiceUtil.search(company.getCompanyId(), searchTerms.getKeywords(), searchTerms.getStatus(), userParams, searchContainer.getStart(), searchContainer.getEnd(), searchContainer.getOrderByComparator());
                }
                searchContainer.setTotalVar(String.valueOf(total));
                searchContainer.setResultsAndTotal(results);
            %>
        </liferay-ui:search-container-results>
        
        <liferay-ui:search-container-row
            className="com.liferay.portal.kernel.model.User"
            escapedModel="<%= true %>"
            keyProperty="userId"
            modelVar="user2"
            rowIdProperty="screenName">

            <liferay-ui:search-container-column-text
                name="name"
                property="fullName"
                truncate="<%= true %>"
            />
    
            <liferay-ui:search-container-column-text
                name="screen-name"
                property="screenName"
                truncate="<%= true %>"
            />
            
            <liferay-ui:search-container-column-text
                name="email-address"
                property="emailAddress"
                truncate="<%= false %>"
            />
                            
        </liferay-ui:search-container-row>

        <liferay-ui:search-iterator
            displayStyle="<%= displayStyle %>"
            markupView="lexicon"
        />
    </liferay-ui:search-container>
</aui:form>

<aui:script use="liferay-search-container">
    var searchContainer = Liferay.SearchContainer.get('<portlet:namespace />users');

    searchContainer.on(
        'rowToggled',
        function(event) {
            var selectedItems = event.elements.allSelectedElements;

            Liferay.Util.getOpener().Liferay.fire(
                '<%= HtmlUtil.escapeJS(eventName) %>',
                {
                    data: selectedItems.attr('value').join(',')
                }
            );
        }
    );
</aui:script>

Please help us to resolve the issue.

Jamie Sammons, modified 1 Year ago. New Member Posts: 12 Join Date: 4/18/24 Recent Posts

I have attached all my codes.

Can someone help me on the above issue ?

Olaf Kock, modified 1 Year ago. New Member Posts: 12 Join Date: 4/18/24 Recent Posts

Hi Olaf, Could you please help us to resolve the above issue ?

thumbnail
Olaf Kock, modified 1 Year ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts

Check line 45 of your code...

Sorry for the sneakyness... but seriously:

Due to the links, we know the documentation that you followed. But we don't know what you actually did.

In order to help identifying issues in your code, it would help to be able to look at your code. Ideally a minimal version that just shows the problem.