📄 contactroleselectavailable.jsp
字号:
<%@ page import="com.sourcetap.sfa.code.*" %>
<%@ page import="com.sourcetap.sfa.ui.UIUtility" %>
<%@ page import="com.sourcetap.sfa.util.EntityHelper" %>
<%@ page import="org.ofbiz.entity.model.DynamicViewEntity" %>
<%@ page import="org.ofbiz.base.util.Debug" %>
<%@ include file="/includes/header.jsp" %>
<%
boolean DEBUG = true;
String module = "contactRoleSelectAvailable";
if (DEBUG) Debug.logVerbose("[contactRoleSelectAvailable] Start 1", module);
String contactId = "";
if (request.getParameter("contactId")!=null) {
contactId = request.getParameter("contactId");
} else {
Debug.logWarning("[contactRoleSelectAvailable.jsp] Error. Contact ID was not set.", module);
return;
}
DynamicViewEntity dve = EntityHelper.createDynamicViewEntity( delegator, "RoleType");
dve.addMemberEntity("Code", "Code");
dve.addViewLink("RoleType", "Code", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("roleTypeId", "codeId")));
dve.addAlias("Code", "codeTypeId", null, null, null, null, null);
EntityCondition condition = new EntityConditionList(UtilMisc.toList(
new EntityExpr("codeTypeId", EntityOperator.EQUALS, "ROLE_TYPE_SFA")),
EntityOperator.AND);
try {
List eligibleEntityL = delegator.findByCondition("RoleType", condition, null, orderBy);
// Create a list of items already selected.
int assignedOptionCount = 0;
if (request.getParameter("assignedOptionCount")!=null) {
assignedOptionCount = Integer.valueOf(request.getParameter("assignedOptionCount")).intValue();
}
ArrayList assignedOptionList = new ArrayList();
for (int optionNbr = 0; optionNbr < assignedOptionCount; optionNbr++) {
String paramName = "assignedValue_" + String.valueOf(optionNbr);
if (request.getParameter(paramName)!=null) {
// Build a primary key from the key string of the assigned option.
String assignedOption = request.getParameter(paramName);
HashMap keyMap = new HashMap();
keyMap.put("roleTypeId", assignedOption.substring("roleTypeId:".length()));
GenericPK assignedOptionPK = new GenericPK(delegator.getModelEntity("RoleType"), keyMap);
assignedOptionList.add(assignedOptionPK);
} else {
Debug.logVerbose("[contactRoleSelectAvailable] " + paramName + " parameter not found", module);
}
}
// Remove the assigned options from the available list.
eligibleEntityL = UIUtility.removeSelectedEligibleEntities(
assignedOptionList,
eligibleEntityL);
StringBuffer sb = new StringBuffer("<SELECT NAME=\"ContactRoleSelectRealTimeAvailSelect\" ID=\"ContactRoleSelectRealTimeAvailSelect\">\n");
Iterator eligibleEntityI = eligibleEntityL.iterator();
while(eligibleEntityI.hasNext()){
GenericValue eligibleGV = (GenericValue)eligibleEntityI.next();
sb.append("<OPTION VALUE=\"codeTypeId:" + eligibleGV.getString("codeTypeId") + "&codeId:" + eligibleGV.getString("codeId") + "\">" + eligibleGV.getString("codeValue") + "</OPTION>\n");
}
sb.append("</SELECT>");
Debug.logVerbose("[contactRoleSelectAvailable] Html String: " + sb.toString());
out.write(sb.toString());
} catch (Exception e) {
Debug.logError("[contactRoleSelectAvailable] Error executing getEligibleEntities: " + e.getLocalizedMessage(), module);
}
%>
<%@ include file="/includes/footer.jsp" %>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -