📄 viewgeneric.jsp
字号:
<%-- * Copyright (c) 2001 The Open For Business Project - www.ofbiz.org * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * *@author <a href='mailto:jonesde@ofbiz.org'>David E. Jones (jonesde@ofbiz.org)</a> *@created Aug 18 2001 *@version 1.0--%><%@ page import="java.text.*, java.util.*, java.net.*" %><%@ page import="org.ofbiz.security.*, org.ofbiz.entity.*, org.ofbiz.base.util.*, org.ofbiz.webapp.pseudotag.*" %><%@ page import="org.ofbiz.entity.model.*" %><%@ taglib uri="ofbizTags" prefix="ofbiz" %><jsp:useBean id="security" type="org.ofbiz.security.Security" scope="request" /><jsp:useBean id="delegator" type="org.ofbiz.entity.GenericDelegator" scope="request" /><%try {%><%String entityName = request.getParameter("entityName");%><%ModelReader reader = delegator.getModelReader();%><%ModelEntity entity = reader.getModelEntity(entityName);%><%boolean hasAllView = security.hasEntityPermission("ENTITY_DATA", "_VIEW", session);%><%boolean hasAllCreate = security.hasEntityPermission("ENTITY_DATA", "_CREATE", session);%><%boolean hasAllUpdate = security.hasEntityPermission("ENTITY_DATA", "_UPDATE", session);%><%boolean hasAllDelete = security.hasEntityPermission("ENTITY_DATA", "_DELETE", session);%><%boolean hasViewPermission = hasAllView || security.hasEntityPermission(entity.getPlainTableName(), "_VIEW", session);%><%boolean hasCreatePermission = hasAllCreate || security.hasEntityPermission(entity.getPlainTableName(), "_CREATE", session);%><%boolean hasUpdatePermission = hasAllUpdate || security.hasEntityPermission(entity.getPlainTableName(), "_UPDATE", session);%><%boolean hasDeletePermission = hasAllDelete || security.hasEntityPermission(entity.getPlainTableName(), "_DELETE", session);%><%if(hasViewPermission){%><% boolean useValue = true; String rowClass1 = "viewOneTR1"; String rowClass2 = "viewOneTR2"; String rowClass = ""; String curFindString = "entityName=" + entityName; GenericPK findByPK = delegator.makePK(entityName, null); for(int fnum = 0; fnum < entity.getPksSize(); fnum++) { ModelField field = entity.getPk(fnum); ModelFieldType type = delegator.getEntityFieldType(entity, field.getType()); String fval = request.getParameter(field.getName()); if(fval != null && fval.length() > 0) { curFindString = curFindString + "&" + field.getName() + "=" + fval; findByPK.setString(field.getName(), fval); } } curFindString = UtilFormatOut.encodeQuery(curFindString); GenericValue value = null; //only try to find it if this is a valid primary key... if(findByPK.isPrimaryKey()) value = delegator.findByPrimaryKey(findByPK); if(value == null) useValue = false;%><br/><STYLE> .topouter { overflow: visible; border-style: none; } .topcontainer { POSITION: absolute; VISIBILITY: visible; width: 90%; border-style: none; } .topcontainerhidden { POSITION: absolute; VISIBILITY: hidden; }</STYLE><script language="JavaScript" type="text/javascript"> var numTabs=<%=entity.getRelationsSize()+2%>;function ShowTab(lname) { for(inc=1; inc <= numTabs; inc++) { document.getElementById('tab' + inc).className = (lname == 'tab' + inc) ? 'ontab' : 'offtab'; document.getElementById('lnk' + inc).className = (lname == 'tab' + inc) ? 'onlnk' : 'offlnk'; document.getElementById('area' + inc).className = (lname == 'tab' + inc) ? 'topcontainer' : 'topcontainerhidden'; }}</script><div style='color: white; background-color: black; padding:3;'> <b>View Entity: <%=entityName%> with PK: <%=findByPK.toString()%></b></div><a href='<ofbiz:url>/FindGeneric?entityName=<%=entityName%></ofbiz:url>' class="buttontext">[Find <%=entityName%>]</a><%if (hasCreatePermission) {%> <a href='<ofbiz:url>/ViewGeneric?entityName=<%=entityName%></ofbiz:url>' class="buttontext">[Create New <%=entityName%>]</a><%}%><%if (value != null) {%> <%if (hasDeletePermission) {%> <a href='<ofbiz:url>/UpdateGeneric?UPDATE_MODE=DELETE&<%=curFindString%></ofbiz:url>' class="buttontext">[Delete this <%=entityName%>]</a> <%}%><%}%><br/><br/><table cellpadding='0' cellspacing='0'><tr> <td id='tab1' class='ontab'> <a href='javascript:ShowTab("tab1")' id=lnk1 class=onlnk>View <%=entityName%></a> </td> <%if (hasUpdatePermission || hasCreatePermission) {%> <td id='tab2' class='offtab'> <a href='javascript:ShowTab("tab2")' id=lnk2 class=offlnk>Edit <%=entityName%></a> </td> <%}%></tr><%if (value != null) {%><tr> <%for(int tabIndex = 0; tabIndex < entity.getRelationsSize(); tabIndex++){%> <%ModelRelation relation = entity.getRelation(tabIndex);%> <%ModelEntity relatedEntity = reader.getModelEntity(relation.getRelEntityName());%> <%if (hasAllView || security.hasEntityPermission(relatedEntity.getPlainTableName(), "_VIEW", session)) {%> <td id='tab<%=tabIndex+3%>' class='offtab'> <a href='javascript:ShowTab("tab<%=tabIndex+3%>")' id='lnk<%=tabIndex+3%>' class='offlnk' style='FONT-SIZE: xx-small;'> <%=relation.getTitle()%><%=relation.getRelEntityName()%></a><SPAN class='tabletext' style='FONT-SIZE: xx-small;'>(<%=relation.getType()%>)</SPAN> </td> <%}%> <%if ((tabIndex+1)%4 == 0) {%></tr><tr><%}%> <%}%></tr><%}%></table><div class='topouter'> <DIV id='area1' class='topcontainer' width="1%"><table border="0" cellspacing="2" cellpadding="2"><%if (value == null) {%><tr class="<%=rowClass1%>"><td><h3>Specified <%=entityName%> was not found.</h3></td></tr><%} else {%> <%for (int fnum = 0; fnum < entity.getFieldsSize(); fnum++) {%> <%ModelField field = entity.getField(fnum);%> <%ModelFieldType type = delegator.getEntityFieldType(entity, field.getType());%> <%rowClass=(rowClass==rowClass1?rowClass2:rowClass1);%><tr class="<%=rowClass%>"> <td valign="top"><div class="tabletext"><b><%=field.getName()%></b></div></td> <td valign="top"> <div class="tabletext"> <%if(type.getJavaType().equals("Timestamp") || type.getJavaType().equals("java.sql.Timestamp")){%> <%java.sql.Timestamp dtVal = value.getTimestamp(field.getName());%> <%=dtVal==null?"":dtVal.toString()%> <%} else if(type.getJavaType().equals("Date") || type.getJavaType().equals("java.sql.Date")){%> <%java.sql.Date dateVal = value.getDate(field.getName());%> <%=dateVal==null?"":dateVal.toString()%> <%} else if(type.getJavaType().equals("Time") || type.getJavaType().equals("java.sql.Time")){%> <%java.sql.Time timeVal = value.getTime(field.getName());%> <%=timeVal==null?"":timeVal.toString()%> <%}else if(type.getJavaType().indexOf("Integer") >= 0){%> <%=UtilFormatOut.safeToString((Integer)value.get(field.getName()))%> <%}else if(type.getJavaType().indexOf("Long") >= 0){%> <%=UtilFormatOut.safeToString((Long)value.get(field.getName()))%> <%}else if(type.getJavaType().indexOf("Double") >= 0){%> <%=UtilFormatOut.safeToString((Double)value.get(field.getName()))%> <%}else if(type.getJavaType().indexOf("Float") >= 0){%> <%=UtilFormatOut.safeToString((Float)value.get(field.getName()))%> <%}else if(type.getJavaType().indexOf("String") >= 0){%> <%=UtilFormatOut.checkNull((String)value.get(field.getName()))%> <%}%> </div> </td> </tr> <%}%><%} //end if value == null %></table> </div><%GenericValue valueSave = value;%><%if(hasUpdatePermission || hasCreatePermission){%> <DIV id='area2' class='topcontainerhidden' width="1%"><%boolean showFields = true;%><%if(value == null && (findByPK.getAllFields().size() > 0)){%> <%=entity.getEntityName()%> with primary key <%=findByPK.toString()%> not found.<br/><%}%><% String lastUpdateMode = request.getParameter("UPDATE_MODE"); if((session.getAttribute("_ERROR_MESSAGE_") != null || request.getAttribute("_ERROR_MESSAGE_") != null) && lastUpdateMode != null && !lastUpdateMode.equals("DELETE")) { //if we are updating and there is an error, don't use the entity data for the fields, use parameters to get the old value useValue = false; }%><form action='<ofbiz:url>/UpdateGeneric?entityName=<%=entityName%></ofbiz:url>' method="POST" name="updateForm" style="margin:0;"><table cellpadding="2" cellspacing="2" border="0"><%if (value == null) {%> <%if (hasCreatePermission) {%> You may create a <%=entityName%> by entering the values you want, and clicking Update. <input type="hidden" name="UPDATE_MODE" value="CREATE"/> <%for (int fnum = 0; fnum < entity.getPksSize();fnum++) {%> <%ModelField field = entity.getPk(fnum);%> <%ModelFieldType type = delegator.getEntityFieldType(entity, field.getType());%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -