<%@ 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.web.Actions"%> <%@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 + "."; String rowStyle = "border-bottom: 1px solid;"; boolean resizeColumns = style.allowsResizeColumns() && XavaPreferences.getInstance().isResizeColumns(); String browser = request.getHeader("user-agent"); boolean scrollSupported = !(browser != null && (browser.indexOf("MSIE 6") >= 0 || browser.indexOf("MSIE 7") >= 0)); String styleOverflow = org.openxava.web.Lists.getOverflow(browser, subview.getMetaPropertiesList()); String collectionClass = subview.isEditable()?"class='" + style.getElementCollection() + "'":""; 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 && scrollSupported) { %>
<% } %> style="<%=style.getListStyle()%>"> <% 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?style.getListPair():style.getListOdd(); String cssCellClass=f%2==0?style.getListPairCell():style.getListOddCell(); String idRow = Ids.decorate(request, propertyPrefix) + f; String events=f%2==0?style.getListPairEvents():style.getListOddEvents(); String newRowStyle = subview.isCollectionEditable() && f == rowCount - 1?"display: none;":""; String lastRowEvent = subview.isCollectionEditable() && f >= rowCount - 2?"onchange='elementCollectionEditor.onChangeRow(this, "+ f + ")'":""; String actionsStyle = subview.isCollectionEditable() && f >= rowCount - 2?"style='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"; %> style="border-bottom: 1px solid; <%=newRowStyle%>"> <% 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()?"vertical-align: middle;text-align: right; ":"vertical-align: middle; "; String cellStyle = style.getListCellStyle() + align; int columnWidth = subview.getCollectionColumnWidth(columnIndex); String width = columnWidth<0 || !resizeColumns?"":"width: " + columnWidth + "px"; 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) { %><% } %>
width="5"/> <% } %> <% // 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?"":"width: " + columnWidth + "px"; 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=<%=style.getListHeaderCell()%> style="padding-right: 0px">
" style="overflow: hidden; <%=width%>" > <%if (resizeColumns) {%><%}%> <%=label%>  <%if (resizeColumns) {%><%}%>
> <%if (sortable) { %> <%}%> <%if (!Is.emptyString(removeSelectedAction)) {%> <%} else if (suppressRemoveAction){%> <%} else { %> <% String onclick="elementCollectionEditor.removeRow('" + app + "', '" + module + "', this, " + f + ", " + hasTotals + ")"; %> <% if (style.isUseIconsInsteadOfImages()) { %> <% } else { %> <% } %> <%} %> <% if (labelOnEachCell) { %> <%=p.getQualifiedLabel(request)%> <% } %>
> <% if (!subview.isCollectionMembersEditables()) {%> <% if (referenceName == null) { %> <%=fvalue%>  <% } else { %> <% } %> <% } else if (referenceName != null) { %> <% } else { %> '/>"> <% } %>
<% if (resizeColumns && scrollSupported) { %>
<% } %>