📄 sectiondetail.jsp
字号:
<%@ page import="org.ofbiz.entity.*" %>
<%@ page import="org.ofbiz.entity.model.*" %>
<%@ page import="java.lang.reflect.Method" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.Timestamp" %>
<%@ page import="org.ofbiz.entity.util.SequenceUtil" %>
<%@ include file="/includes/header.jsp" %>
<%!
// Define function to get all entities (screen section entities) associated with a section.
Iterator getUiScreenSectionEntityIterator(String sectionId,
GenericDelegator delegator)
throws GenericEntityException {
HashMap uiScreenSectionEntityMap = new HashMap();
uiScreenSectionEntityMap.put("sectionId", sectionId);
ArrayList order = new ArrayList();
order.add("entityId");
List uiScreenSectionEntitys = delegator.findByAnd("UiScreenSectionEntity", uiScreenSectionEntityMap, order);
return uiScreenSectionEntitys.iterator();
}
// Define function to get all attributes (screen section infos) associated with a section.
Iterator getUiScreenSectionInfoIterator(String sectionId,
GenericDelegator delegator)
throws GenericEntityException {
HashMap uiScreenSectionInfoMap = new HashMap();
uiScreenSectionInfoMap.put("sectionId", sectionId);
ArrayList order = new ArrayList();
order.add("partyId");
order.add("displayOrder");
List uiScreenSectionInfos = delegator.findByAnd("UiScreenSectionInfo", uiScreenSectionInfoMap, order);
return uiScreenSectionInfos.iterator();
}
// Define function to add missing eligible attributes.
void addMissingAttributes(String sectionId,
GenericDelegator delegator,
String partyId)
throws GenericEntityException {
ModelEntity uiScreenSectionInfoEntity = delegator.getModelEntity("UiScreenSectionInfo");
// Get the entities associated with this screen section.
Iterator uiScreenSectionEntityIterator2 = getUiScreenSectionEntityIterator(sectionId, delegator);
// Loop through entities associated with this screen section.
while(uiScreenSectionEntityIterator2.hasNext()) {
GenericValue uiScreenSectionEntityDetails = (GenericValue)uiScreenSectionEntityIterator2.next();
// Get the attributes associated with this entity.
HashMap uiAttributeMap = new HashMap();
uiAttributeMap.put("entityId", uiScreenSectionEntityDetails.getString("entityId"));
List uiAttributes = delegator.findByAnd("UiAttribute", uiAttributeMap, null);
Iterator uiAttributeIterator2 = uiAttributes.iterator();
// Loop through all eligible attributes for this entity.
while(uiAttributeIterator2.hasNext()) {
GenericValue uiAttributeDetails = (GenericValue)uiAttributeIterator2.next();
boolean attributeFound = false;
// Get the attributes associated with this screen section.
Iterator uiScreenSectionInfoIterator2 = getUiScreenSectionInfoIterator(sectionId, delegator);
// Loop through the already associated attributes to see if this on is already associated with the section
// for the specified party ID.
while(uiScreenSectionInfoIterator2.hasNext()) {
GenericValue uiScreenSectionInfoDetails = (GenericValue)uiScreenSectionInfoIterator2.next();
// See if this is a match.
if (uiScreenSectionInfoDetails.getString("attributeId").equals(uiAttributeDetails.getString("attributeId")) &&
uiScreenSectionInfoDetails.getString("partyId").equals(partyId)) {
// This is a match. We don't need to add this one.
attributeFound = true;
}
}
// Clear the screen section info iterator so we can loop through it again.
uiScreenSectionInfoIterator2 = null;
if (!attributeFound) {
// This eligible attribute is not associated with the screen section for this party ID. Add it.
GenericValue newUiScreenSectionInfoDetails = new GenericValue(uiScreenSectionInfoEntity);
newUiScreenSectionInfoDetails.setDelegator(delegator);
newUiScreenSectionInfoDetails.set("sectionId", sectionId);
newUiScreenSectionInfoDetails.set("partyId", partyId);
newUiScreenSectionInfoDetails.set("displayObjectId", uiAttributeDetails.getString("displayObjectId"));
newUiScreenSectionInfoDetails.set("attributeId", uiAttributeDetails.getString("attributeId"));
newUiScreenSectionInfoDetails.set("maxLength", uiAttributeDetails.getString("maxLength"));
newUiScreenSectionInfoDetails.set("isMandatory", uiAttributeDetails.getString("isMandatory"));
newUiScreenSectionInfoDetails.set("isReadOnly", uiAttributeDetails.getString("isReadOnly"));
newUiScreenSectionInfoDetails.set("isVisible", uiAttributeDetails.getString("isVisible"));
newUiScreenSectionInfoDetails.set("isSearchable", uiAttributeDetails.getString("isSearchable"));
newUiScreenSectionInfoDetails.set("displayOrder", uiAttributeDetails.getString("displayOrder"));
newUiScreenSectionInfoDetails.set("displayLabel", uiAttributeDetails.getString("displayLabel"));
newUiScreenSectionInfoDetails.set("displayLength", uiAttributeDetails.getString("displayLength"));
newUiScreenSectionInfoDetails.set("startOnNewRow", uiAttributeDetails.getString("startOnNewRow"));
delegator.create(newUiScreenSectionInfoDetails);
}
}
}
}
%>
<%
String ENTITY = "UiScreenSection";
String action = "";
String sectionId = "";
String addAttributes = "";
String searchString = "";
String name = "";
boolean update = false;
String rowClass;
int rowNum;
ModelEntity entity = delegator.getModelEntity(ENTITY);
if(request.getParameter("action") != null){
//actions=search, update, create
action = request.getParameter("action");
}
if(request.getParameter("sectionId") != null){
sectionId = request.getParameter("sectionId");
}
if(request.getParameter("addAttributes") != null){
//actions=search, update, create
addAttributes = request.getParameter("addAttributes");
}
if(action.equals("update")){
GenericValue genericValue = new GenericValue(entity);
genericValue.setDelegator(delegator);
Enumeration params = request.getParameterNames();
while(params.hasMoreElements()){
String pName = (String)params.nextElement();
if(!pName.equals("action"))
genericValue.set(pName, request.getParameter(pName));
}
delegator.store(genericValue);
}
%>
<% // Get the section details
HashMap hashMap = new HashMap();
hashMap.put("sectionId", sectionId);
GenericPK genericPk = new GenericPK(entity, hashMap);
GenericValue sectionDetails = delegator.findByPrimaryKey(genericPk);
// Process the 3 links that add attributes to a screen section.
if(addAttributes.equals("Default")) {
// Need to add screen section attributes for the default party ID (-1).
addMissingAttributes(sectionId, delegator, "-1");
}
/* if(addAttributes.equals("Company")) {
// Need to add screen section attributes for the company party ID.
addMissingAttributes(sectionId, delegator, "");
}
*/
if(addAttributes.equals("User")) {
// Need to add screen section attributes for the user party ID.
addMissingAttributes(sectionId, delegator, userLogin.getString("partyId"));
}
// Get all entities associated with this screen section.
Iterator uiScreenSectionEntityIterator = getUiScreenSectionEntityIterator(sectionId, delegator);
// Get all attributes associated with this screen section.
Iterator uiScreenSectionInfoIterator = getUiScreenSectionInfoIterator(sectionId, delegator);
%>
<!-- title table -->
<table width="100%" height="30"><tr><td><div class="head1">Screen Section Detail</div></td></tr></table>
<table width="100%" valign="top"><tr><td>
<table border=0 width='100%' cellpadding='<%=headerBoxBorderWidth%>' cellspacing='0' class="viewOneHeader"><tr><td width='100%' height='100%'>
<table border="0" width="100%" class="viewOneHeader"><tr>
<td>
Screen Section Details
</td>
<td align="right">
<a href="<ofbiz:url>/screenDetail</ofbiz:url>?screenId=<%=String.valueOf(sectionDetails.get("screenId"))%>">Back to Screen Detail</a>
<% if(!action.equals("showUpdate")) { %>
<a href="<ofbiz:url>/sectionDetail</ofbiz:url>?action=showUpdate&sectionId=<%=sectionId%>">Update</a>
<% } else {%>
<a href="<ofbiz:url>/sectionDetail</ofbiz:url>?sectionId=<%=sectionId%>">Cancel Update</a>
<% } %>
</td>
</tr>
</table>
<table border="0" width="100%" class="viewOneBox">
<form method="post" action="<ofbiz:url>/sectionDetail</ofbiz:url>" >
<input type="hidden" value="update" name="action" >
<input type="hidden" name="sectionId" value="<%=sectionId%>">
<!-- Screen ID -->
<% HashMap screenFields = new HashMap();
screenFields.put("screenId", String.valueOf(sectionDetails.get("screenId")));
GenericValue screenDetails = delegator.findByPrimaryKey("UiScreen", screenFields);
%>
<tr>
<td class="viewOneLabel">Screen</td>
<td class="viewOneField">
<% name="screenName"; %>
<%=screenDetails.getString(name)%>
</td>
</tr>
<!-- Section Name -->
<tr>
<td width="20%" class="viewOneLabel">Section Name</td>
<td width="30%" class="viewOneField">
<% name="sectionName";
if(action.equals("showUpdate")) { %>
<input type="text" name="<%=name%>" value="<%=(String.valueOf(sectionDetails.get(name)) != null ? String.valueOf(sectionDetails.get(name)) : "") %>">
<%} else {%>
<%=sectionDetails.getString(name)%>
<%}%>
</td>
<!-- Layout type -->
<% HashMap layoutTypeFields = new HashMap();
layoutTypeFields.put("layoutTypeId", String.valueOf(sectionDetails.get("layoutTypeId")));
GenericValue layoutTypeDetails = delegator.findByPrimaryKey("UiLayoutType", layoutTypeFields);
String layoutTypeId = layoutTypeDetails.getString("layoutTypeId")==null ? "" : layoutTypeDetails.getString("layoutTypeId");
HashMap statusProps = new HashMap();
statusProps.put("NAME", "layoutTypeId");
statusProps.put("VALUE_FIELD", "layoutTypeId" );
statusProps.put("DISPLAY_FIELD", "layoutName" );
statusProps.put("SELECTED", layoutTypeId);
ArrayList order = new ArrayList();
//order.remove(0);
order.add("layoutName");
String layoutTypeDropDown = buildDropDown(delegator.findAll("UiLayoutType", order), statusProps );
%>
<tr>
<td width="20%" class="viewOneLabel">Layout Type</td>
<td width="80%" colspan="3" class="viewOneField">
<% name="layoutName";
if(action.equals("showUpdate")) { %>
<%=layoutTypeDropDown%>
<%} else {%>
<%=(layoutTypeDetails != null && String.valueOf(layoutTypeDetails.get(name)) != null ? String.valueOf(layoutTypeDetails.get(name)) : "")%>
<%}%>
</td>
</tr>
<!-- Display Order -->
<tr>
<td width="20%" class="viewOneLabel">Display Order</td>
<td width="80%" colspan="3" class="viewOneField">
<% name="displayOrder";
if(action.equals("showUpdate")) { %>
<input type="text" name="<%=name%>" value="<%=(String.valueOf(sectionDetails.get(name)) != null ? String.valueOf(sectionDetails.get(name)) : "") %>">
<%} else {%>
<%=sectionDetails.getString(name)%>
<%}%>
</td>
</tr>
<!-- Row Count -->
<tr>
<td width="20%" class="viewOneLabel">Row Count</td>
<td width="80%" colspan="3" class="viewOneField">
<% name="rowCount";
if(action.equals("showUpdate")) { %>
<input type="text" name="<%=name%>" value="<%=(String.valueOf(sectionDetails.get(name)) != null ? String.valueOf(sectionDetails.get(name)) : "") %>">
<%} else {%>
<%=sectionDetails.getString(name)%>
<%}%>
</td>
</tr>
<!-- Column Count -->
<tr>
<td width="20%" class="viewOneLabel">Column Count</td>
<td width="80%" colspan="3" class="viewOneField">
<% name="columnCount";
if(action.equals("showUpdate")) { %>
<input type="text" name="<%=name%>" value="<%=(String.valueOf(sectionDetails.get(name)) != null ? String.valueOf(sectionDetails.get(name)) : "") %>">
<%} else {%>
<%=sectionDetails.getString(name)%>
<%}%>
</td>
</tr>
<!-- Button Keys -->
<tr>
<td width="20%" class="viewOneLabel">Button Key Definition</td>
<td width="80%" colspan="3" class="viewOneField">
<% name="buttonKeys";
if(action.equals("showUpdate")) { %>
<input type="text" name="<%=name%>" value="<%=(String.valueOf(sectionDetails.get(name)) != null ? String.valueOf(sectionDetails.get(name)) : "") %>">
<%} else {%>
<%=sectionDetails.getString(name)%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -