All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.custom_attribute.page.jsp Maven / Gradle / Ivy

There is a newer version: 7.4.3.112-ga112
Show newest version
<%--
/**
 * 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="/custom_attribute/init.jsp" %>

<%
String randomNamespace = PortalUtil.generateRandomKey(request, "taglib_ui_custom_attribute_page") + StringPool.UNDERLINE;

String className = (String)request.getAttribute("liferay-expando:custom-attribute:className");
long classPK = GetterUtil.getLong((String)request.getAttribute("liferay-expando:custom-attribute:classPK"));
boolean editable = GetterUtil.getBoolean((String)request.getAttribute("liferay-expando:custom-attribute:editable"));
boolean label = GetterUtil.getBoolean((String)request.getAttribute("liferay-expando:custom-attribute:label"));
String name = (String)request.getAttribute("liferay-expando:custom-attribute:name");

ExpandoBridge expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(company.getCompanyId(), className, classPK);
%>



	<%
	int type = expandoBridge.getAttributeType(name);
	Serializable value = expandoBridge.getAttribute(name);
	Serializable defaultValue = expandoBridge.getAttributeDefault(name);

	UnicodeProperties properties = expandoBridge.getAttributeProperties(name);

	boolean propertyHidden = GetterUtil.getBoolean(properties.get(ExpandoColumnConstants.PROPERTY_HIDDEN));
	boolean propertyVisibleWithUpdatePermission = GetterUtil.getBoolean(properties.get(ExpandoColumnConstants.PROPERTY_VISIBLE_WITH_UPDATE_PERMISSION));
	boolean propertySecret = GetterUtil.getBoolean(properties.getProperty(ExpandoColumnConstants.PROPERTY_SECRET));
	int propertyHeight = GetterUtil.getInteger(properties.getProperty(ExpandoColumnConstants.PROPERTY_HEIGHT));
	int propertyWidth = GetterUtil.getInteger(properties.getProperty(ExpandoColumnConstants.PROPERTY_WIDTH));
	String propertyDisplayType = GetterUtil.getString(properties.getProperty(ExpandoColumnConstants.PROPERTY_DISPLAY_TYPE), ExpandoColumnConstants.PROPERTY_DISPLAY_TYPE_TEXT_BOX);

	if (editable && propertyVisibleWithUpdatePermission) {
		propertyHidden = !ExpandoColumnPermissionUtil.contains(permissionChecker, company.getCompanyId(), className, ExpandoTableConstants.DEFAULT_TABLE_NAME, name, ActionKeys.UPDATE);
	}

	String localizedName = LanguageUtil.get(resourceBundle, name);

	if (name.equals(localizedName)) {
		localizedName = HtmlUtil.escape(TextFormatter.format(name, TextFormatter.J));
	}

	Format dateFormatDateTime = FastDateFormatFactoryUtil.getDateTime(locale, timeZone);
	%>

	
		
			
				
					

					
						

							<%
							Boolean curValue = (Boolean)value;

							if (curValue == null) {
								curValue = (Boolean)defaultValue;
							}

							curValue = ParamUtil.getBoolean(request, "ExpandoAttribute--" + name + "--", curValue);
							%>

							
						
						
						
						
							

								<%
								Calendar valueDate = CalendarFactoryUtil.getCalendar(timeZone, locale);

								if (value != null) {
									valueDate.setTime((Date)value);
								}
								else if (defaultValue != null) {
									valueDate.setTime((Date)defaultValue);
								}
								else {
									valueDate.setTime(new Date());
								}

								String fieldParam = "ExpandoAttribute--" + name + "--";

								int day = ParamUtil.getInteger(request, fieldParam + "Day", -1);

								if ((day == -1) && (valueDate != null)) {
									day = valueDate.get(Calendar.DATE);
								}

								int month = ParamUtil.getInteger(request, fieldParam + "Month", -1);

								if ((month == -1) && (valueDate != null)) {
									month = valueDate.get(Calendar.MONTH);
								}

								int year = ParamUtil.getInteger(request, fieldParam + "Year", -1);

								if ((year == -1) && (valueDate != null)) {
									year = valueDate.get(Calendar.YEAR);
								}

								int amPm = ParamUtil.getInteger(request, fieldParam + "AmPm", -1);

								if ((amPm == -1) && (valueDate != null)) {
									amPm = Calendar.AM;

									if (DateUtil.isFormatAmPm(locale)) {
										amPm = valueDate.get(Calendar.AM_PM);
									}
								}

								int hour = ParamUtil.getInteger(request, fieldParam + "Hour", -1);

								if ((hour == -1) && (valueDate != null)) {
									hour = valueDate.get(Calendar.HOUR_OF_DAY);

									if (DateUtil.isFormatAmPm(locale)) {
										hour = valueDate.get(Calendar.HOUR);
									}
								}

								int minute = ParamUtil.getInteger(request, fieldParam + "Minute", -1);

								if ((minute == -1) && (valueDate != null)) {
									minute = valueDate.get(Calendar.MINUTE);
								}
								%>

								

								
							
						
						
						
						

							<%
							double[] curValue = ParamUtil.getDoubleValues(request, "ExpandoAttribute--" + name + "--", (double[])value);
							%>

							
								

									<%
									for (double curDefaultValue : (double[])defaultValue) {
									%>

										

									<%
									}
									%>

								
								

									<%
									for (double curDefaultValue : (double[])defaultValue) {
									%>

										

									<%
									}
									%>

								
								
									
								
								

									<%
									if (curValue.length == 0) {
										curValue = (double[])defaultValue;
									}
									%>

									
								
							
						
						

							<%
							float[] curValue = ParamUtil.getFloatValues(request, "ExpandoAttribute--" + name + "--", (float[])value);
							%>

							
								

									<%
									for (float curDefaultValue : (float[])defaultValue) {
									%>

										

									<%
									}
									%>

								
								

									<%
									for (float curDefaultValue : (float[])defaultValue) {
									%>

										

									<%
									}
									%>

								
								
									
								
								

									<%
									if (curValue.length == 0) {
										curValue = (float[])defaultValue;
									}
									%>

									
								
							
						
						

							<%
							JSONObject geolocationJSONObject = JSONFactoryUtil.createJSONObject(value.toString());
							%>

							
">
var inputName = "<%= portletDisplay.getNamespace()+"ExpandoAttribute--" + HtmlUtil.escapeJS(name) + "--" %>"; var geolocationField = { init: function() { Liferay.MapBase.get( inputName, function(map) { map.on('positionChange', geolocationField.onPositionChange, geolocationField); } ); }, onPositionChange: function(event) { var location = event.newVal.location; var inputNode = document.querySelector('[name="' + inputName + '"]'); if (inputNode) { inputNode.setAttribute( 'value', JSON.stringify( { latitude: location.lat, longitude: location.lng } ) ); } var locationNode = document.getElementById(inputName + 'Location'); if (locationNode) { locationNode.innerHTML = event.newVal.address; } } }; geolocationField.init();
<% int[] curValue = ParamUtil.getIntegerValues(request, "ExpandoAttribute--" + name + "--", (int[])value); %> <% for (int curDefaultValue : (int[])defaultValue) { %> <% } %> <% for (int curDefaultValue : (int[])defaultValue) { %> <% } %> <% if (curValue.length == 0) { curValue = (int[])defaultValue; } %> <% long[] curValue = ParamUtil.getLongValues(request, "ExpandoAttribute--" + name + "--", (long[])value); %> <% for (long curDefaultValue : (long[])defaultValue) { %> <% } %> <% for (long curDefaultValue : (long[])defaultValue) { %> <% } %> <% if (curValue.length == 0) { curValue = (long[])defaultValue; } %> <% Number[] curValue = ParamUtil.getNumberValues(request, "ExpandoAttribute--" + name + "--", (Number[])value); %> <% for (Number curDefaultValue : (Number[])defaultValue) { %> <% } %> <% for (Number curDefaultValue : (Number[])defaultValue) { %> <% } %> <% if (curValue.length == 0) { curValue = (Number[])defaultValue; } %> <% short[] curValue = ParamUtil.getShortValues(request, "ExpandoAttribute--" + name + "--", (short[])value); %> <% for (short curDefaultValue : (short[])defaultValue) { %> <% } %> <% for (short curDefaultValue : (short[])defaultValue) { %> <% } %> <% if (curValue.length == 0) { curValue = (short[])defaultValue; } %> <% String[] curValue = ParamUtil.getStringValues(request, "ExpandoAttribute--" + name + "--", (String[])value); %> <% for (String curDefaultValue : (String[])defaultValue) { %> <% } %> <% for (String curDefaultValue : (String[])defaultValue) { %> <% } %> <% if (curValue.length == 0) { curValue = (String[])defaultValue; } %> <% String xml = ParamUtil.getString(request, "ExpandoAttribute--" + name + "--"); if (Validator.isNull(xml) && (value != null)) { xml = LocalizationUtil.updateLocalization((Map)value, StringPool.BLANK, "Data", LocaleUtil.toLanguageId(locale)); } if (Validator.isNull(xml) && (defaultValue != null)) { xml = LocalizationUtil.updateLocalization((Map)defaultValue, StringPool.BLANK, "Data", LocaleUtil.toLanguageId(locale)); } %> <% value = ParamUtil.getString(request, "ExpandoAttribute--" + name + "--", String.valueOf(value)); if (Validator.isNull(String.valueOf(value))) { value = defaultValue; } %> 0 %>"> width: <%= propertyWidth %>px;
" type="<%= propertySecret ? "password" : "text" %>" value="<%= HtmlUtil.escape(String.valueOf(value)) %>" /> <% StringBundler sb = new StringBundler(); if (type == ExpandoColumnConstants.BOOLEAN) { sb.append((Boolean)value); } else if (type == ExpandoColumnConstants.BOOLEAN_ARRAY) { if (!Arrays.equals((boolean[])value, (boolean[])defaultValue)) { sb.append(StringUtil.merge((boolean[])value)); } } else if (type == ExpandoColumnConstants.DATE) { sb.append(dateFormatDateTime.format((Date)value)); } else if (type == ExpandoColumnConstants.DATE_ARRAY) { if (!Arrays.deepEquals((Date[])value, (Date[])defaultValue)) { Date[] dates = (Date[])value; for (int i = 0; i < dates.length; i++) { if (i != 0) { sb.append(StringPool.COMMA_AND_SPACE); } sb.append(dateFormatDateTime.format(dates[i])); } } } else if (type == ExpandoColumnConstants.DOUBLE) { sb.append((Double)value); } else if (type == ExpandoColumnConstants.DOUBLE_ARRAY) { sb.append(StringUtil.merge((double[])value)); } else if (type == ExpandoColumnConstants.FLOAT) { sb.append((Float)value); } else if (type == ExpandoColumnConstants.FLOAT_ARRAY) { sb.append(StringUtil.merge((float[])value)); } else if (type == ExpandoColumnConstants.GEOLOCATION) { sb.append(value.toString()); } else if (type == ExpandoColumnConstants.INTEGER) { sb.append((Integer)value); } else if (type == ExpandoColumnConstants.INTEGER_ARRAY) { sb.append(StringUtil.merge((int[])value)); } else if (type == ExpandoColumnConstants.LONG) { sb.append((Long)value); } else if (type == ExpandoColumnConstants.LONG_ARRAY) { sb.append(StringUtil.merge((long[])value)); } else if (type == ExpandoColumnConstants.NUMBER) { sb.append((Number)value); } else if (type == ExpandoColumnConstants.NUMBER_ARRAY) { sb.append(StringUtil.merge((Number[])value)); } else if (type == ExpandoColumnConstants.SHORT) { sb.append((Short)value); } else if (type == ExpandoColumnConstants.SHORT_ARRAY) { sb.append(StringUtil.merge((short[])value)); } else if (type == ExpandoColumnConstants.STRING_ARRAY) { sb.append(StringUtil.merge((String[])value)); } else if (type == ExpandoColumnConstants.STRING_LOCALIZED) { Map values = (Map)value; sb.append(values.get(locale)); } else { sb.append((String)value); } %> <%= HtmlUtil.escape(sb.toString()) %> <% JSONObject geolocationJSONObject = JSONFactoryUtil.createJSONObject(value.toString()); %>
">




© 2015 - 2024 Weber Informatics LLC | Privacy Policy