
META-INF.resources.common.addresses.jsp Maven / Gradle / Ivy
<%--
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
--%>
<%@ include file="/init.jsp" %>
<%
String className = (String)request.getAttribute("addresses.className");
long classPK = (Long)request.getAttribute("addresses.classPK");
List addresses = Collections.emptyList();
int[] addressesIndexes = null;
String addressesIndexesParam = ParamUtil.getString(request, "addressesIndexes");
if (Validator.isNotNull(addressesIndexesParam)) {
addresses = new ArrayList();
addressesIndexes = StringUtil.split(addressesIndexesParam, 0);
for (int addressesIndex : addressesIndexes) {
addresses.add(new AddressImpl());
}
}
else {
if (classPK > 0) {
addresses = AddressServiceUtil.getAddresses(className, classPK);
addressesIndexes = new int[addresses.size()];
for (int i = 0; i < addresses.size(); i++) {
addressesIndexes[i] = i;
}
}
if (addresses.isEmpty()) {
addresses = new ArrayList();
addresses.add(new AddressImpl());
addressesIndexes = new int[] {0};
}
if (addressesIndexes == null) {
addressesIndexes = new int[0];
}
}
%>
<%
for (int i = 0; i < addressesIndexes.length; i++) {
int addressesIndex = addressesIndexes[i];
Address address = addresses.get(i);
long countryId = ParamUtil.getLong(request, "addressCountryId" + addressesIndex, address.getCountryId());
long regionId = ParamUtil.getLong(request, "addressRegionId" + addressesIndex, address.getRegionId());
%>
<%@ include file="/common/addresses_address.jspf" %>
new Liferay.DynamicSelect(
[
{
select: ' addressCountryId<%= addressesIndex %>',
selectData: Liferay.Address.getCountries,
selectDesc: 'nameCurrentValue',
selectId: 'countryId',
selectSort: '<%= true %>',
selectVal: '<%= countryId %>'
},
{
select: ' addressRegionId<%= addressesIndex %>',
selectData: Liferay.Address.getRegions,
selectDesc: 'name',
selectId: 'regionId',
selectVal: '<%= regionId %>'
}
]
);
<%
}
%>
new Liferay.AutoFields(
{
contentBox: '# addresses',
fieldIndexes: ' addressesIndexes',
namespace: ' ',
on: {
'clone': function(event) {
var guid = event.guid;
var row = event.row;
var dynamicSelects = row.one('select[data-componentType=dynamic_select]');
if (dynamicSelects) {
dynamicSelects.detach('change');
}
new Liferay.DynamicSelect(
[
{
select: ' addressCountryId' + guid,
selectData: Liferay.Address.getCountries,
selectDesc: 'nameCurrentValue',
selectId: 'countryId',
selectSort: '<%= true %>',
selectVal: '0'
},
{
select: ' addressRegionId' + guid,
selectData: Liferay.Address.getRegions,
selectDesc: 'name',
selectId: 'regionId',
selectVal: '0'
}
]
);
}
}
}
).render();
© 2015 - 2025 Weber Informatics LLC | Privacy Policy