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

META-INF.resources.xava.reference.jsp Maven / Gradle / Ivy

<%@ include file="imports.jsp"%>

<%@page import="java.util.Collection" %>
<%@page import="java.util.Map" %>
<%@page import="org.openxava.model.meta.MetaReference" %>
<%@page import="org.openxava.view.meta.MetaPropertyView" %>
<%@page import="org.openxava.web.Ids"%>
<%@page import="org.openxava.web.WebEditors"%>
<%@page import="org.openxava.web.DescriptionsLists"%> 
<%@page import="org.openxava.util.XavaPreferences"%>
<%@page import="org.openxava.util.Is"%>





<%
boolean onlyEditor = "true".equalsIgnoreCase(request.getParameter("onlyEditor"));
boolean frame = "true".equalsIgnoreCase(request.getParameter("frame")); 
boolean composite = "true".equalsIgnoreCase(request.getParameter("composite"));
boolean descriptionsList = "true".equalsIgnoreCase(request.getParameter("descriptionsList"));
String viewObject = request.getParameter("viewObject");
viewObject = (viewObject == null || viewObject.equals(""))?"xava_view":viewObject;
org.openxava.view.View view = (org.openxava.view.View) context.get(request, viewObject);
String referenceKey = request.getParameter("referenceKey");
MetaReference ref = (MetaReference) request.getAttribute(referenceKey);
String refViewObject = request.getParameter("refViewObject");
if (Is.emptyString(refViewObject)) refViewObject = viewObject; 
String labelKey = "xava_label_" + referenceKey;
if (!descriptionsList) descriptionsList = view.displayAsDescriptionsList(ref);
boolean descriptionsListAndReferenceView = descriptionsList || !composite?false:view.displayAsDescriptionsListAndReferenceView(ref);
if (descriptionsListAndReferenceView) {
	composite = false;
}
%>

<%@ include file="htmlTagsEditor.jsp"%>

<%
String editableKey = referenceKey + "_EDITABLE_";
boolean editable = view.isEditable(ref.getName()); 
int labelFormat = view.getLabelFormatForReference(ref);
String labelStyle = view.getLabelStyleForReference(ref);
if (Is.empty(labelStyle)) labelStyle = XavaPreferences.getInstance().getDefaultLabelStyle();
String label = view.getLabelFor(ref);
%>

<% if (view.isFlowLayout()) { %>
	
<% } %> <% if (!onlyEditor) { %> <%=preLabel%> <% if (labelFormat == MetaPropertyView.NORMAL_LABEL) { %> '/>" class="<%= labelStyle%>"> <%=label%> <% } %> <%=postLabel%> <%=preEditor%> <% if (labelFormat == MetaPropertyView.SMALL_LABEL) { %> '/>' class="<%=style.getSmallLabel()%> <%=labelStyle %>"> <%=label%>
<% } %> <% } // !onlyEditor %> <% Collection keys = ref.getMetaModelReferenced().getAllKeyPropertiesNames(); String keyProperty = ""; String keyProperties = ""; String propertyKey = null; if (keys.size() == 1) { keyProperty = keys.iterator().next().toString(); propertyKey = Ids.decorate(request, referenceKey + "." + keyProperty); if (!composite) { Map values = (Map) view.getValue(ref.getName()); values = values == null?java.util.Collections.EMPTY_MAP:values; Object value = values.get(keyProperty); String valueKey = propertyKey + ".value"; request.setAttribute(valueKey, value); String fvalue = value==null?"":value.toString(); request.setAttribute(propertyKey + ".fvalue", fvalue); } } else { propertyKey = referenceKey + DescriptionsLists.COMPOSITE_KEY_SUFFIX; Map values = null; if (!composite) { values = (Map) view.getValue(ref.getName()); values = values == null?java.util.Collections.EMPTY_MAP:values; } java.util.Iterator it = keys.iterator(); StringBuffer sb = new StringBuffer(); while (it.hasNext()) { String property = (String) it.next(); if (!composite) { Object value = values.get(property); String valueKey = Ids.decorate(request, referenceKey + "." + property) + ".value"; request.setAttribute(valueKey, value); } sb.append(property); if (it.hasNext()) { sb.append(','); } } if (!composite) { String key = ref.getMetaModelReferenced().toString(values); String fvalue = key==null?"0":key; request.setAttribute(propertyKey + ".fvalue", fvalue); } keyProperties = sb.toString(); } %> <% if (!composite) { %> <% String wrapperClass = view.isEditable() && ref.isRequired()?style.getRequiredEditor():""; wrapperClass = view.throwsReferenceChanged(ref)?wrapperClass + " xava_onchange":wrapperClass; wrapperClass = Is.emptyString(wrapperClass)?"":"class='" + wrapperClass + "'"; %> '/>" <%=wrapperClass%> data-property="<%=propertyKey%>"> <% } %> <% boolean notCompositeEditorClosed = false; %> <% if (descriptionsList || descriptionsListAndReferenceView) { String descriptionProperty = view.getDescriptionPropertyInDescriptionsList(ref); String descriptionProperties = view.getDescriptionPropertiesInDescriptionsList(ref); String parameterValuesProperties=view.getParameterValuesPropertiesInDescriptionsList(ref); String condition = view.getConditionInDescriptionsList(ref); boolean orderByKey = view.isOrderByKeyInDescriptionsList(ref); String order = view.getOrderInDescriptionsList(ref); org.openxava.tab.meta.MetaTab metaTab = ref.getMetaModelReferenced().getMetaComponent().getMetaTab(); String filter = view.getFilterInDescriptionsList(ref); if (Is.emptyString(filter) && metaTab.hasFilter()) { filter = metaTab.getMetaFilter().getClassName(); } if (metaTab.hasBaseCondition()) { if (org.openxava.util.Is.emptyString(condition)) { condition = metaTab.getBaseCondition(); } else { condition = metaTab.getBaseCondition() + " AND " + condition; } } %> <% if (descriptionsListAndReferenceView) { %> <%@ include file="referenceActions.jsp"%> <% notCompositeEditorClosed = true; %> <% String editorURL = "editors/" + WebEditors.getMetaEditorFor(ref, view.getViewName()).getUrl() + "?propertyKey=" + propertyKey + "&viewObject=" + refViewObject + "&editable=false"; %> <% } %> <% } else { String editorURL = "editors/" + WebEditors.getMetaEditorFor(ref, view.getViewName()).getUrl() + "?propertyKey=" + propertyKey + "&viewObject=" + refViewObject + "&editable=" + editable; %> <% } %> <% if (!frame) { %> <%@ include file="referenceActions.jsp"%> <%@ include file="referenceActionsExt.jsp"%> <% } %> <% if (!composite && !notCompositeEditorClosed) { %> <% } if (!onlyEditor) { %> <%=postEditor%> <%}%> <% if (view.isFlowLayout()) { %>
<% } %>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy