Author: jonesde
Date: Tue May 1 04:41:43 2007 New Revision: 534015 URL: http://svn.apache.org/viewvc?view=rev&rev=534015 Log: A number of fixes and restored a bunch of functionality that was in the ViewGeneric page before the JSP to FTL conversion; now all appears to be working properly Modified: ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.properties ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.bsh ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewGeneric.bsh ofbiz/trunk/framework/webtools/webapp/webtools/entity/ViewGeneric.ftl Modified: ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.properties URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.properties?view=diff&rev=534015&r1=534014&r2=534015 ============================================================================== --- ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.properties (original) +++ ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.properties Tue May 1 04:41:43 2007 @@ -270,8 +270,7 @@ WebtoolsShowShowWSDL=Show wsdl WebtoolsSize=Size WebtoolsSizeTotal=Size Total -WebtoolsSpecifiedEntity1=Specified Entity -WebtoolsSpecifiedEntity2=was not found +WebtoolsNoValueFoundFor=No value found for WebtoolsStatsMainPageTitle=Server Statistics Since Start WebtoolsStatsBinsPageTitle=Server Statistic Bins History Page Modified: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.bsh URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.bsh?view=diff&rev=534015&r1=534014&r2=534015 ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.bsh Tue May 1 04:41:43 2007 @@ -41,7 +41,7 @@ import javolution.util.FastList; import javolution.util.FastMap; -String entityName = request.getParameter("entityName"); +String entityName = parameters.get("entityName"); ModelReader reader = delegator.getModelReader(); ModelEntity modelEntity = reader.getModelEntity(entityName); @@ -59,7 +59,7 @@ context.put("hasUpdatePermission", hasUpdatePermission); context.put("hasDeletePermission", hasDeletePermission); -String find = request.getParameter("find"); +String find = parameters.get("find"); if (find == null) { find = "false"; } @@ -69,7 +69,7 @@ GenericEntity findByEntity = delegator.makeValue(entityName, null); for (int fnum = 0; fnum < modelEntity.getFieldsSize(); fnum++) { ModelField field = modelEntity.getField(fnum); - String fval = request.getParameter(field.getName()); + String fval = parameters.get(field.getName()); if (fval != null) { if (fval.length() > 0) { curFindString = curFindString + "&" + field.getName() + "=" + fval; @@ -80,7 +80,7 @@ curFindString = UtilFormatOut.encodeQuery(curFindString); context.put("curFindString", curFindString); -String viewIndexString = (String)request.getParameter("VIEW_INDEX"); +String viewIndexString = (String)parameters.get("VIEW_INDEX"); if (viewIndexString == null || viewIndexString.length() == 0) { viewIndexString = "0"; } @@ -95,15 +95,15 @@ context.put("viewIndexPrevious", viewIndex-1); context.put("viewIndexNext", viewIndex+1); -String viewSizeString = (String)request.getParameter("VIEW_SIZE"); +String viewSizeString = (String)parameters.get("VIEW_SIZE"); if (viewSizeString == null || viewSizeString.length() == 0) { - viewSizeString = "10"; + viewSizeString = "10"; } - + int viewSize = 10; -try { - viewSize = Integer.valueOf(viewSizeString).intValue(); -} catch (NumberFormatException nfe) { +try { + viewSize = Integer.valueOf(viewSizeString).intValue(); +} catch (NumberFormatException nfe) { viewSize = 10; } context.put("viewSize", viewSize); @@ -178,7 +178,7 @@ fieldMap.put("isPk", (field.getIsPk() == true) ? "Y" : "N"); fieldMap.put("javaType", type.getJavaType()); fieldMap.put("sqlType", type.getSqlType()); - fieldMap.put("param", (request.getParameter(field.getName()) != null ? request.getParameter(field.getName()) : "")); + fieldMap.put("param", (parameters.get(field.getName()) != null ? parameters.get(field.getName()) : "")); fieldList.add(fieldMap); } Modified: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewGeneric.bsh URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewGeneric.bsh?view=diff&rev=534015&r1=534014&r2=534015 ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewGeneric.bsh (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewGeneric.bsh Tue May 1 04:41:43 2007 @@ -31,16 +31,16 @@ import java.sql.Timestamp; import java.sql.Date; import java.sql.Time; +import javolution.util.FastList; +import javolution.util.FastMap; -delegator = request.getAttribute("delegator"); -security = request.getAttribute("security"); - -String entityName = request.getParameter("entityName"); +String entityName = parameters.get("entityName"); context.put("entityName", entityName); ModelReader reader = delegator.getModelReader(); ModelEntity entity = reader.getModelEntity(entityName); +context.put("entity", entity); context.put("plainTableName", entity.getPlainTableName()); boolean hasAllView = security.hasEntityPermission("ENTITY_DATA", "_VIEW", session); @@ -67,7 +67,7 @@ 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()); + String fval = parameters.get(field.getName()); if (fval != null && fval.length() > 0) { curFindString = curFindString + "&" + field.getName() + "=" + fval; findByPK.setString(field.getName(), fval); @@ -89,26 +89,10 @@ useValue = false; } -List relationList = new ArrayList(); -for(int tabIndex = 0; tabIndex < entity.getRelationsSize(); tabIndex++) { - Map relation = new HashMap(); - - ModelRelation modelRelation = entity.getRelation(tabIndex); - ModelEntity relatedEntity = reader.getModelEntity(modelRelation.getRelEntityName()); - if (hasAllView || security.hasEntityPermission(relatedEntity.getPlainTableName(), "_VIEW", session)) { - relation.put("tab", "tab"+(tabIndex+3)); - relation.put("title", modelRelation.getTitle()); - relation.put("relEntityName", modelRelation.getRelEntityName()); - relation.put("type", modelRelation.getType()); - } - relationList.add(relation); -} -context.put("relations", relationList); - if (value != null) { - List fieldList = new ArrayList(); + List fieldList = FastList.newInstance(); for (int fnum = 0; fnum < entity.getFieldsSize(); fnum++) { - Map mapField = new HashMap(); + Map mapField = FastMap.newInstance(); ModelField field = entity.getField(fnum); ModelFieldType type = delegator.getEntityFieldType(entity, field.getType()); @@ -149,7 +133,7 @@ } context.put("pkNotFound", pkNotFound); -String lastUpdateMode = request.getParameter("UPDATE_MODE"); +String lastUpdateMode = parameters.get("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, do not use the entity data for the fields, use parameters to get the old value @@ -157,9 +141,9 @@ } context.put("useValue", useValue); -List newFieldPkList = new ArrayList(); +List newFieldPkList = FastList.newInstance(); for (int fnum = 0; fnum < entity.getPksSize();fnum++) { - Map mapField = new HashMap(); + Map mapField = FastMap.newInstance(); ModelField field = entity.getPk(fnum); ModelFieldType type = delegator.getEntityFieldType(entity, field.getType()); @@ -175,7 +159,7 @@ dateTimeString = dtVal.toString(); } } else if (!useValue) { - dateTimeString = request.getParameter(field.getName()); + dateTimeString = parameters.get(field.getName()); } fieldValue = UtilFormatOut.checkNull(dateTimeString); fieldType = "DateTime"; @@ -185,7 +169,7 @@ Date dateVal = findByPK.getDate(field.getName()); dateString = (dateVal == null) ? "" : dateVal.toString(); } else if (!useValue) { - dateString = request.getParameter(field.getName()); + dateString = parameters.get(field.getName()); } fieldValue = UtilFormatOut.checkNull(dateString); fieldType = "Date"; @@ -195,31 +179,31 @@ Time timeVal = findByPK.getTime(field.getName()); timeString = (timeVal == null) ? "" : timeVal.toString(); } else if (!useValue) { - timeString = request.getParameter(field.getName()); + timeString = parameters.get(field.getName()); } fieldValue = UtilFormatOut.checkNull(timeString); fieldType = "Time"; } else if (type.getJavaType().indexOf("Integer") >= 0) { - fieldValue = (findByPK != null && useValue) ? UtilFormatOut.safeToString((Integer)findByPK.get(field.getName())) : (useValue ? "" : UtilFormatOut.checkNull(request.getParameter(field.getName()))); + fieldValue = (findByPK != null && useValue) ? UtilFormatOut.safeToString((Integer)findByPK.get(field.getName())) : (useValue ? "" : UtilFormatOut.checkNull(parameters.get(field.getName()))); fieldType = "Integer"; } else if (type.getJavaType().indexOf("Long") >= 0) { - fieldValue = (findByPK != null && useValue) ? UtilFormatOut.safeToString((Long)findByPK.get(field.getName())) : (useValue ? "" : UtilFormatOut.checkNull(request.getParameter(field.getName()))); + fieldValue = (findByPK != null && useValue) ? UtilFormatOut.safeToString((Long)findByPK.get(field.getName())) : (useValue ? "" : UtilFormatOut.checkNull(parameters.get(field.getName()))); fieldType = "Long"; } else if (type.getJavaType().indexOf("Double") >= 0) { - fieldValue = (findByPK != null && useValue) ? UtilFormatOut.safeToString((Double)findByPK.get(field.getName())) : (useValue ? "" : UtilFormatOut.checkNull(request.getParameter(field.getName()))); + fieldValue = (findByPK != null && useValue) ? UtilFormatOut.safeToString((Double)findByPK.get(field.getName())) : (useValue ? "" : UtilFormatOut.checkNull(parameters.get(field.getName()))); fieldType = "Double"; } else if (type.getJavaType().indexOf("Float") >= 0) { - fieldValue = (findByPK != null && useValue) ? UtilFormatOut.safeToString((Float)findByPK.get(field.getName())) : (useValue ? "" : UtilFormatOut.checkNull(request.getParameter(field.getName()))); + fieldValue = (findByPK != null && useValue) ? UtilFormatOut.safeToString((Float)findByPK.get(field.getName())) : (useValue ? "" : UtilFormatOut.checkNull(parameters.get(field.getName()))); fieldType = "Float"; } else if (type.getJavaType().indexOf("String") >= 0) { if (type.stringLength() <= 80) { - fieldValue = (findByPK != null && useValue) ? UtilFormatOut.checkNull((String)findByPK.get(field.getName())) : (useValue ? "" : UtilFormatOut.checkNull(request.getParameter(field.getName()))); + fieldValue = (findByPK != null && useValue) ? UtilFormatOut.checkNull((String)findByPK.get(field.getName())) : (useValue ? "" : UtilFormatOut.checkNull(parameters.get(field.getName()))); fieldType = "StringOneRow"; } else if (type.stringLength() <= 255){ - fieldValue = (findByPK != null && useValue) ? UtilFormatOut.checkNull((String)findByPK.get(field.getName())) : (useValue ? "" : UtilFormatOut.checkNull(request.getParameter(field.getName()))); + fieldValue = (findByPK != null && useValue) ? UtilFormatOut.checkNull((String)findByPK.get(field.getName())) : (useValue ? "" : UtilFormatOut.checkNull(parameters.get(field.getName()))); fieldType = "String"; } else { - fieldValue = (findByPK != null && useValue) ? UtilFormatOut.checkNull((String)findByPK.get(field.getName())):(useValue?"":UtilFormatOut.checkNull(request.getParameter(field.getName()))); + fieldValue = (findByPK != null && useValue) ? UtilFormatOut.checkNull((String)findByPK.get(field.getName())):(useValue?"":UtilFormatOut.checkNull(parameters.get(field.getName()))); fieldType = "Textarea"; } stringLength = type.stringLength().toString(); @@ -233,9 +217,9 @@ } context.put("newFieldPkList", newFieldPkList); -List newFieldNoPkList = new ArrayList(); +List newFieldNoPkList = FastList.newInstance(); for (int fnum = 0; fnum < entity.getNopksSize();fnum++) { - Map mapField = new HashMap(); + Map mapField = FastMap.newInstance(); ModelField field = entity.getNopk(fnum); ModelFieldType type = delegator.getEntityFieldType(entity, field.getType()); @@ -251,7 +235,7 @@ dateTimeString = dtVal.toString(); } } else if (!useValue) { - dateTimeString = request.getParameter(field.getName()); + dateTimeString = parameters.get(field.getName()); } fieldValue = UtilFormatOut.checkNull(dateTimeString); fieldType = "DateTime"; @@ -261,7 +245,7 @@ Date dateVal = value.getDate(field.getName()); dateString = (dateVal == null) ? "" : dateVal.toString(); } else if (!useValue) { - dateString = request.getParameter(field.getName()); + dateString = parameters.get(field.getName()); } fieldValue = UtilFormatOut.checkNull(dateString); fieldType = "Date"; @@ -271,31 +255,31 @@ Time timeVal = value.getTime(field.getName()); timeString = (timeVal == null) ? "" : timeVal.toString(); } else if (!useValue) { - timeString = request.getParameter(field.getName()); + timeString = parameters.get(field.getName()); } fieldValue = UtilFormatOut.checkNull(timeString); fieldType = "Time"; } else if (type.getJavaType().indexOf("Integer") >= 0) { - fieldValue = (value != null && useValue) ? UtilFormatOut.safeToString((Integer)value.get(field.getName())):UtilFormatOut.checkNull(request.getParameter(field.getName())); + fieldValue = (value != null && useValue) ? UtilFormatOut.safeToString((Integer)value.get(field.getName())):UtilFormatOut.checkNull(parameters.get(field.getName())); fieldType = "Integer"; } else if (type.getJavaType().indexOf("Long") >= 0) { - fieldValue = (value != null && useValue) ? UtilFormatOut.safeToString((Long)value.get(field.getName())):UtilFormatOut.checkNull(request.getParameter(field.getName())); + fieldValue = (value != null && useValue) ? UtilFormatOut.safeToString((Long)value.get(field.getName())):UtilFormatOut.checkNull(parameters.get(field.getName())); fieldType = "Long"; } else if (type.getJavaType().indexOf("Double") >= 0) { - fieldValue = (value != null && useValue) ? UtilFormatOut.safeToString((Double)value.get(field.getName())):UtilFormatOut.checkNull(request.getParameter(field.getName())); + fieldValue = (value != null && useValue) ? UtilFormatOut.safeToString((Double)value.get(field.getName())):UtilFormatOut.checkNull(parameters.get(field.getName())); fieldType = "Double"; } else if (type.getJavaType().indexOf("Float") >= 0) { - fieldValue = (value != null && useValue) ? UtilFormatOut.safeToString((Float)value.get(field.getName())):UtilFormatOut.checkNull(request.getParameter(field.getName())); + fieldValue = (value != null && useValue) ? UtilFormatOut.safeToString((Float)value.get(field.getName())):UtilFormatOut.checkNull(parameters.get(field.getName())); fieldType = "Float"; } else if (type.getJavaType().indexOf("String") >= 0) { if (type.stringLength() <= 80) { - fieldValue = (value != null && useValue) ? UtilFormatOut.checkNull((String)value.get(field.getName())):UtilFormatOut.checkNull(request.getParameter(field.getName())); + fieldValue = (value != null && useValue) ? UtilFormatOut.checkNull((String)value.get(field.getName())):UtilFormatOut.checkNull(parameters.get(field.getName())); fieldType = "StringOneRow"; } else if (type.stringLength() <= 255) { - fieldValue = (value != null && useValue) ? UtilFormatOut.checkNull((String)value.get(field.getName())):UtilFormatOut.checkNull(request.getParameter(field.getName())); + fieldValue = (value != null && useValue) ? UtilFormatOut.checkNull((String)value.get(field.getName())):UtilFormatOut.checkNull(parameters.get(field.getName())); fieldType = "String"; } else { - fieldValue = (value != null && useValue) ? UtilFormatOut.checkNull((String)value.get(field.getName())):UtilFormatOut.checkNull(request.getParameter(field.getName())); + fieldValue = (value != null && useValue) ? UtilFormatOut.checkNull((String)value.get(field.getName())):UtilFormatOut.checkNull(parameters.get(field.getName())); fieldType = "Textarea"; } stringLength = type.stringLength().toString(); @@ -309,9 +293,9 @@ } context.put("newFieldNoPkList", newFieldNoPkList); -List relationFieldList = new ArrayList(); +List relationFieldList = FastList.newInstance(); for (int relIndex = 0; relIndex < entity.getRelationsSize(); relIndex++) { - Map mapRelation = new HashMap(); + Map mapRelation = FastMap.newInstance(); ModelRelation relation = entity.getRelation(relIndex); ModelEntity relatedEntity = reader.getModelEntity(relation.getRelEntityName()); @@ -321,8 +305,9 @@ relCreate = true; } - mapRelation.put("relIndex", relIndex + 3); + mapRelation.put("type", relation.getType()); mapRelation.put("title", relation.getTitle()); + mapRelation.put("relEntityName", relation.getRelEntityName()); mapRelation.put("relatedTable", relatedEntity.getEntityName()); mapRelation.put("relCreate", relCreate); @@ -335,9 +320,9 @@ valueRelated = (GenericValue) tempIter.next(); } - List relatedFieldsList = new ArrayList(); + List relatedFieldsList = FastList.newInstance(); for (int fnum = 0; fnum < relatedEntity.getFieldsSize(); fnum++) { - Map mapRelatedFields = new HashMap(); + Map mapRelatedFields = FastMap.newInstance(); ModelField field = relatedEntity.getField(fnum); ModelFieldType type = delegator.getEntityFieldType(entity, field.getType()); Modified: ofbiz/trunk/framework/webtools/webapp/webtools/entity/ViewGeneric.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/entity/ViewGeneric.ftl?view=diff&rev=534015&r1=534014&r2=534015 ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/entity/ViewGeneric.ftl (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/entity/ViewGeneric.ftl Tue May 1 04:41:43 2007 @@ -19,6 +19,21 @@ <#assign enableEdit = parameters.enableEdit?default("false")> +<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()+1)}; +function ShowTab(lname) { + for(inc=1; inc <= numTabs; inc++) { + document.getElementById('area' + inc).className = (lname == 'tab' + inc) ? 'topcontainer' : 'topcontainerhidden'; + } +} +</script> + <h1>${uiLabelMap.WebtoolsViewValue}</h1> <br /> <h2>${uiLabelMap.WebtoolsForEntity}: ${entityName}</h2> @@ -42,18 +57,21 @@ <br /> <#if value?has_content> - <form name="relationForm" action='<@ofbizUrl>ViewGeneric?entityName=${entityName}&contactMechId=${parameters.contactMechId?if_exists}</@ofbizUrl>' method="POST"> + <form name="relationForm"> <p>${uiLabelMap.CommonView}:</p> - <select name="viewRelated" onchange='javascript:document.relationForm.submit();'> - <option value="void">${entityName}</option> - <#list relations as relation> - <option value="${relation.tab}"<#if relation.tab = parameters.viewRelated?default("void")> selected="selected"</#if>>${relation.title}${relation.relEntityName} (${relation.type})</option> + <select name="viewRelated" onchange="javascript:ShowTab(this.options[this.selectedIndex].value)"> + <option value="tab1">${entityName}</option> + <#list relationFieldList as relation> + <option value="tab${(relation_index+2)}">${relation.title}${relation.relEntityName} (${relation.type})</option> </#list> </select> </form> <br /> </#if> +<div class="topouter"> +<div id="area1" class="topcontainer" width="1%"> + <div class="screenlet"> <div class="screenlet-title-bar"> <h3>${uiLabelMap.WebtoolsEntityCurrentValue}</h3> @@ -76,7 +94,6 @@ <#if enableEdit = "true"> <#if hasUpdatePermission || hasCreatePermission> - <br /> <#assign alt_row = false> <div id="area2" class="screenlet"> <div class="screenlet-title-bar"> @@ -203,24 +220,22 @@ </div> </#if> </#if> +</div> <#if relationFieldList?has_content> - <#assign viewRelated = parameters.viewRelated?default("void")> <#list relationFieldList as relation> - <#assign tabName = "tab" + relation.relIndex> - <#if tabName = viewRelated> - <br /> + <div id="area${(relation_index + 2)}" class="topcontainerhidden" width="100%"> <div class="screenlet"> <div class="screenlet-title-bar"> <ul> - <li class="head3">${relation.title} ${uiLabelMap.WebtoolsRelatedEntity}: ${relation.relatedTable}</li> + <li class="head3">${uiLabelMap.WebtoolsRelatedEntity}: ${relation.title}${relation.relatedTable} (${relation.type})</li> + <li><a href="<@ofbizUrl>FindGeneric?${relation.encodeRelatedEntityFindString}&find=true</@ofbizUrl>">${uiLabelMap.CommonFind}</a></li> <#if relation.valueRelated?has_content> - <li><a href='<@ofbizUrl>ViewGeneric?${relation.encodeRelatedEntityFindString}</@ofbizUrl>'>${uiLabelMap.CommonView}</a></li> - <#else> - <#if hasAllCreate || relCreate> - <li><a href='<@ofbizUrl>ViewGeneric?${relation.encodeRelatedEntityFindString}&enableEdit=true</@ofbizUrl>'>${uiLabelMap.CommonCreate}</a></li> - </#if> + <li><a href="<@ofbizUrl>ViewGeneric?${relation.encodeRelatedEntityFindString}</@ofbizUrl>">${uiLabelMap.CommonView}</a></li> </#if> + <#if hasAllCreate || relCreate> + <li><a href="<@ofbizUrl>ViewGeneric?${relation.encodeRelatedEntityFindString}&enableEdit=true</@ofbizUrl>">${uiLabelMap.CommonCreate}</a></li> + </#if> </ul> <br class="clear"/> </div> @@ -240,9 +255,15 @@ </#list> </table> <#else> - ${uiLabelMap.WebtoolsSpecifiedEntity1} ${relation.relatedTable} ${uiLabelMap.WebtoolsSpecifiedEntity2}. + <#if "one" = relation.type> + <div>${uiLabelMap.WebtoolsNoValueFoundFor}: ${relation.title}${relation.relatedTable}.</div> + <#else/> + <div><a href="<@ofbizUrl>FindGeneric?${relation.encodeRelatedEntityFindString}&find=true</@ofbizUrl>">${uiLabelMap.CommonFind}</a></div> + </#if> </#if> </div> - </#if> + </div> </#list> </#if> +<br class="clear"/> +</div> |
Free forum by Nabble | Edit this page |