📄 editprep.bsh
字号:
/* * $Id: editprep.bsh 5462 2005-08-05 18:35:48Z jonesde $ * * Copyright (c) 2003 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. * */import java.util.ArrayList;import java.util.Collection;import java.util.HashMap;import java.util.Iterator;import java.util.LinkedList;import java.util.List;import java.util.Map;import java.util.Set;import java.util.TreeSet;import org.ofbiz.widget.html.*;import org.ofbiz.widget.form.*;import org.ofbiz.base.util.*;import org.ofbiz.entity.*;import org.ofbiz.security.*;import org.ofbiz.service.*;import org.ofbiz.entity.model.*;import javax.servlet.*;import javax.servlet.http.*;/** * * @author <a href="mailto:byersa@automationgroups.com">Al Byers</a> * @version $Rev: 5462 $ * @since 2.1 * This is a crude general script to find entity data based on the primary key. * It only works on entities with one primary key field and it relies on that being * in the pagedef config file. * It could get and interrogate a GenericEntity object */ security = request.getAttribute("security");// Get permission from pagedef config fileString permission = page.getProperty("permission");String formDefFile = page.getProperty("formDefFile");String singleFormName = page.getProperty("singleFormName");String entityName = page.getProperty("entityName");String priKeyName = page.getProperty("priKeyName");String defaultMapName = page.getProperty("defaultMapName");if( defaultMapName == null) defaultMapName = "valueObject";if(security.hasEntityPermission(permission, "_VIEW", session)) { context.put("hasPermission", Boolean.TRUE);} else { context.put("hasPermission", Boolean.FALSE);}LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher");GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");HashMap currentEntityMap = (HashMap)session.getAttribute("currentEntityMap");if(currentEntityMap == null){ currentEntityMap = new HashMap(); session.setAttribute("currentEntityMap", currentEntityMap);}GenericPK currentPK = currentEntityMap.get(entityName);genericValue = delegator.findByPrimaryKey(currentPK);HtmlFormWrapper editWrapper = new HtmlFormWrapper(formDefFile, singleFormName, request, response);editWrapper.putInContext(defaultMapName, genericValue);// The idea here is that by setting the map name here, dependency on the // widget-form config file could be eliminated.ModelForm modelForm = editWrapper.getModelForm();modelForm.setDefaultMapName(defaultMapName);context.put("editWrapper", editWrapper);//context.put(priKeyName, priKeyValue);return "success";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -