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

META-INF.resources.xava.editors.elementCollectionEditor.jsp Maven / Gradle / Ivy

There is a newer version: 7.4.3
Show newest version
<%@ include file="../imports.jsp"%>

<%@page import="java.util.Iterator"%>
<%@page import="java.util.Collection"%>
<%@page import="java.util.Map"%>
<%@page import="org.openxava.controller.meta.MetaAction"%>
<%@page import="org.openxava.web.Ids"%>
<%@page import="org.openxava.controller.meta.MetaControllers"%>
<%@page import="org.openxava.util.Is"%>
<%@page import="org.openxava.util.Maps"%>
<%@page import="org.openxava.util.XavaPreferences"%>
<%@page import="org.openxava.view.View"%>
<%@page import="org.openxava.model.meta.MetaProperty"%>
<%@page import="org.openxava.model.meta.MetaReference"%> 
<%@page import="org.openxava.web.DescriptionsLists"%> 
<%@page import="org.openxava.web.WebEditors"%>





<%
String collectionName = request.getParameter("collectionName");
String viewObject = request.getParameter("viewObject");
String viewName = viewObject + "_" + collectionName;
View view = (View) context.get(request, viewObject);
View subview = view.getSubview(collectionName);
String idCollection = org.openxava.web.Collections.id(request, collectionName);
String propertyPrefixAccumulated = request.getParameter("propertyPrefix");
String propertyPrefix = propertyPrefixAccumulated == null?collectionName + ".":propertyPrefixAccumulated + collectionName + ".";

boolean resizeColumns = style.allowsResizeColumns() && XavaPreferences.getInstance().isResizeColumns();
String collectionClass = subview.isEditable()?"ox-element-collection":"";
boolean sortable = subview.isCollectionSortable();
String removeSelectedAction = subview.getRemoveSelectedCollectionElementsAction();
boolean suppressRemoveAction = removeSelectedAction != null && "".equals(removeSelectedAction);
boolean labelOnEachCell = "true".equals(request.getParameter("labelOnEachCell"));
boolean hideTotals = "true".equals(request.getParameter("hideTotals"));
%>
<% if (resizeColumns) { %>
<% } %> > <% if (sortable) { %><% } %> <% if (subview.isCollectionEditable()) { %> <% if (ref != null && subview.isSearchForReference(ref) && subview.isLastSearchKey(p.getName())) { %> <% } %> <% } %> <% // Values Collection values = subview.getCollectionValues(); if (values == null) values = java.util.Collections.EMPTY_LIST; int rowCount = subview.isCollectionEditable()?values.size() + 2:values.size(); for (int f=0; f < rowCount; f++) { String cssClass=f%2==0?"ox-list-pair":"ox-list-odd"; String cssCellClass=f%2==0?"ox-list-pair":"ox-list-odd"; String idRow = Ids.decorate(request, propertyPrefix) + f; String events=f%2==0?style.getListPairEvents():style.getListOddEvents(); String newRowStyle = subview.isCollectionEditable() && f == rowCount - 1?"ox-display-none":""; String lastRowClass = subview.isCollectionEditable() && f >= rowCount - 2?"xava_onchange_last_row":""; String actionsStyle = subview.isCollectionEditable() && f >= rowCount - 2?"class='ox-visibility-hidden'":""; String app = request.getParameter("application"); String module = request.getParameter("module"); boolean hasTotals = subview.hasCollectionTotals(); String sortableClass = subview.isCollectionEditable() && f >= rowCount - 2?"":"xava_sortable_element_row"; %> > <% if (subview.isCollectionEditable()) { %> <% } %> <% it = subview.getMetaPropertiesList().iterator(); for (int columnIndex = 0; it.hasNext(); columnIndex++) { MetaProperty p = (MetaProperty) it.next(); String align =p.isNumber() && !p.hasValidValues()?"ox-text-align-right":""; int columnWidth = subview.getCollectionColumnWidth(columnIndex); String width = columnWidth<0 || !resizeColumns?"":"data-width=" + columnWidth; String referenceName = null; String searchAction = null; if (p.getName().contains(".")) { String refName = org.openxava.util.Strings.noLastTokenWithoutLastDelim(p.getName(), "."); if (subview.displayAsDescriptionsList(subview.getMetaReference(refName))) { referenceName = collectionName + "." + f + "." + refName; } else { View refView = subview.getSubview(refName); if (refView.isSearch()) searchAction = refView.getSearchAction(); } } String propertyName = collectionName + "." + f + "." + p.getName(); boolean throwPropertyChanged = subview.throwsPropertyChanged(p.getName()); Object fvalue = null; if (!subview.isCollectionMembersEditables()) { Object value = view.getValue(propertyName); fvalue = org.openxava.web.WebEditors.formatToStringOrArray(request, p, value, errors, view.getViewName(), false); } %> <% if (searchAction != null && subview.isLastSearchKey(p.getName())) { %> <% } %> <% } } %> <% if (!hideTotals) { %> <% } %> <% if (sortable) { %><% } %>
<% } %> <% // Heading Iterator it = subview.getMetaPropertiesList().iterator(); for (int columnIndex=0; it.hasNext(); columnIndex++) { MetaProperty p = (MetaProperty) it.next(); String label = p.getQualifiedLabel(request); int columnWidth = subview.getCollectionColumnWidth(columnIndex); String width = columnWidth<0 || !resizeColumns?"":"data-width=" + columnWidth; MetaReference ref = null; if (p.getName().contains(".")) { String refName = org.openxava.util.Strings.noLastTokenWithoutLastDelim(p.getName(), "."); ref = subview.getMetaReference(refName); } String headerId = ""; String dataDefaultValue = ""; if (p.hasNotDependentDefaultValueCalculator() || ref != null && ref.hasNotDependentDefaultValueCalculator()) { Object defaultValue = null; String propertyId = null; if (ref != null && subview.displayAsDescriptionsList(ref) && ref.getMetaModelReferenced().getAllKeyPropertiesNames().size() > 1) { java.util.Map refValues = subview.getSubview(ref.getName()).getValues(); defaultValue = p.getMetaModel().toString(refValues); propertyId = ref.getName() + DescriptionsLists.COMPOSITE_KEY_SUFFIX; } else { if (ref != null && subview.displayAsDescriptionsList(ref) && !p.isKey()) { MetaProperty key = (MetaProperty) p.getMetaModel().getMetaPropertiesKey().iterator().next(); p = key.cloneMetaProperty(); p.setName(ref.getName() + "." + key.getName()); } if (org.openxava.web.WebEditors.mustToFormat(p, subview.getViewName())) { Object value = subview.getDefaultValueInElementCollection(p.getName()); defaultValue = value==null?null:org.openxava.web.WebEditors.formatToStringOrArray(request, p, value, errors, subview.getViewName(), false); propertyId = p.getName(); } } if (defaultValue instanceof String) { // We don't support arrays by now dataDefaultValue = "data-default-value='" + defaultValue + "'"; String id = Ids.decorate(request, collectionName + ".H." + propertyId); headerId = "id='" + id + "'"; } } %> <%=dataDefaultValue%> class="ox-list-header ox-padding-right-0">
" <%=width%>> <%if (resizeColumns) {%><%}%> <%=label%>  <%if (resizeColumns) {%><%}%>
> <%if (sortable) { %> <%}%> <%if (!Is.emptyString(removeSelectedAction)) {%> <%} else if (suppressRemoveAction){%> <%} else { %> <% if (style.isUseIconsInsteadOfImages()) { %> <% } else { %> <% } %> <%} %> <% if (labelOnEachCell) { %> <%=p.getQualifiedLabel(request)%> <% } %>
data-row="<%=f%>"> <% if (!subview.isCollectionMembersEditables()) {%> <% if (referenceName == null) { %> <%=fvalue%>  <% } else { %> <% } %> <% } else if (referenceName != null) { %> <% } else { %> '/>" class="xava_editor"> <% } %>
<% if (resizeColumns) { %>
<% } %>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy