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

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

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

<%@page import="java.util.Map"%>
<%@page import="org.openxava.model.meta.MetaProperty"%>
<%@page import="org.openxava.view.View"%>
<%@page import="java.util.Collections"%>




<%
String viewObject = request.getParameter("viewObject");
View view = (View) context.get(request, viewObject);
String collectionName = request.getParameter("collectionName");
String contextPath = (String) request.getAttribute("xava.contextPath");
if (contextPath == null) contextPath = request.getContextPath();
if (!org.openxava.util.Is.emptyString(collectionName)) {
	view = view.getSubview(collectionName);
}
String propertyKey = request.getParameter("propertyKey");
MetaProperty p = (MetaProperty) request.getAttribute(propertyKey);
boolean editable = "true".equals(request.getParameter("editable")); 
boolean label = org.openxava.util.XavaPreferences.getInstance().isReadOnlyAsLabel();
Object value = request.getAttribute(propertyKey + ".value") == null ? "" : request.getAttribute(propertyKey + ".value");
Map validValues = view.getValidValues(p.getName()) == null ? Collections.emptyMap(): view.getValidValues(p.getName()) ;
Object description = validValues.get(value);
String optionHidden = new String(new char[p.getSize()]).replace("\0", "A");
String firstOption = "";
if (value != null && !validValues.isEmpty() && !validValues.containsValue(value)){
    firstOption = value.toString();
}
%>
    
<%
if (editable) { 
   	if (validValues.isEmpty()) {
%>
	 type="text" tabindex="1" maxlength="<%=p.getSize()%>" size="<%=p.getSize()%>" value="<%=value%>" title="<%=p.getDescription(request)%>"/>
<%
	} else {
%>
    
maxlength="<%=p.getSize()%>" size="<%=p.getSize()%>" value="<%=value%>"/>
<% } } else { if (label) { %> <%=description%> <% } else { %> type="text" title="<%=p.getDescription(request)%>" maxlength="<%=p.getSize()%>" size="<%=p.getSize()%>" value="<%=description%>" disabled/> <% } %> <% } %>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy