svn commit: r578754 - in /ofbiz/trunk/applications/content: src/org/ofbiz/content/survey/SurveyWrapper.java template/survey/genericsurvey.ftl

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r578754 - in /ofbiz/trunk/applications/content: src/org/ofbiz/content/survey/SurveyWrapper.java template/survey/genericsurvey.ftl

jonesde
Author: jonesde
Date: Mon Sep 24 03:54:59 2007
New Revision: 578754

URL: http://svn.apache.org/viewvc?rev=578754&view=rev
Log:
A couple of fixes/cleanup, and added support for state/province and country fields

Modified:
    ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java
    ofbiz/trunk/applications/content/template/survey/genericsurvey.ftl

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java?rev=578754&r1=578753&r2=578754&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java Mon Sep 24 03:54:59 2007
@@ -133,12 +133,7 @@
             String surveyMultiRespColId = surveyQuestionAndAppl.getString("surveyMultiRespColId");
             if (UtilValidate.isNotEmpty(surveyMultiRespColId)) {
                 String surveyMultiRespId = surveyQuestionAndAppl.getString("surveyMultiRespId");
-                List surveyQuestionAndApplList = (List) sqaaWithColIdListByMultiRespId.get(surveyMultiRespId);
-                if (surveyQuestionAndApplList == null) {
-                    surveyQuestionAndApplList = FastList.newInstance();
-                    sqaaWithColIdListByMultiRespId.put(surveyMultiRespId, surveyQuestionAndApplList);
-                }
-                surveyQuestionAndApplList.add(surveyQuestionAndAppl);
+                UtilMisc.addToListInMap(surveyQuestionAndAppl, sqaaWithColIdListByMultiRespId, surveyMultiRespId);
             }
         }
 
@@ -154,6 +149,7 @@
         templateContext.put("surveyResponseId", responseId);
         templateContext.put("sequenceSort", UtilMisc.toList("sequenceNum"));
         templateContext.put("additionalFields", passThru);
+        templateContext.put("delegator", this.delegator);
 
         Template template = this.getTemplate(templateUrl);
         try {

Modified: ofbiz/trunk/applications/content/template/survey/genericsurvey.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/template/survey/genericsurvey.ftl?rev=578754&r1=578753&r2=578754&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/template/survey/genericsurvey.ftl (original)
+++ ofbiz/trunk/applications/content/template/survey/genericsurvey.ftl Mon Sep 24 03:54:59 2007
@@ -87,6 +87,20 @@
         <option value="">Nothing to choose</option>
       </#if>
     </select>
+  <#elseif surveyQuestionAndAppl.surveyQuestionTypeId == "STATE_PROVINCE"/>
+    <select class="selectBox" name="${questionFieldName}">
+    <#assign states = Static["org.ofbiz.common.CommonWorkers"].getStateList(delegator)>
+    <#list states as state>
+        <option value='${state.geoId}'>${state.geoName?default(state.geoId)}</option>
+    </#list>
+    </select>
+  <#elseif surveyQuestionAndAppl.surveyQuestionTypeId == "COUNTRY"/>
+    <select class="selectBox" name="${questionFieldName}">
+    <#assign countries = Static["org.ofbiz.common.CommonWorkers"].getCountryList(delegator)>
+    <#list countries as country>
+        <option value='${country.geoId}'>${country.get("geoName",locale)?default(country.geoId)}</option>
+    </#list>
+    </select>
   <#else/>
     <div class="tabletext">Unsupported question type : ${surveyQuestionAndAppl.surveyQuestionTypeId}</div>
   </#if>
@@ -121,6 +135,8 @@
 
 <table width="100%" border="0" cellpadding="2" cellspacing="0">
   <#assign lastSurveyMultiRespId = ""/>
+  <#assign haveOpenMultiRespHeader = false/>
+  
   <#list surveyQuestionAndAppls as surveyQuestionAndAppl>
    <#if !alreadyShownSqaaPkWithColId.contains(surveyQuestionAndAppl.getPrimaryKey())>
     <#-- Get and setup MultiResp info for this question -->
@@ -144,6 +160,7 @@
     
     <#-- this is before the rest because it will be done if the current row is not a MultiResp (or is different MultiResp) but the last row was... -->
     <#if closeMultiRespHeader>
+      <#assign haveOpenMultiRespHeader = false/>
           </table>
         </td>
       </tr>
@@ -151,6 +168,7 @@
   
     <#-- -->
     <#if openMultiRespHeader>
+      <#assign haveOpenMultiRespHeader = true/>
       <tr width="100%">
         <td colspan="5" width="100%">
           <table width="100%" border="1" cellpadding="1" cellspacing="0">
@@ -168,7 +186,7 @@
     </#if>
   
   <#if surveyMultiResp?has_content>
-    <#assign sqaaWithColIdList = sqaaWithColIdListByMultiRespId[surveyMultiResp.surveyMultiRespId]/>
+    <#assign sqaaWithColIdList = (sqaaWithColIdListByMultiRespId[surveyMultiResp.surveyMultiRespId])?if_exists/>
     <tr>
       <td align="left">
         <@renderSurveyQuestionText surveyQuestionAndAppl=surveyQuestionAndAppl/>
@@ -236,6 +254,12 @@
   </#if>
    </#if>
   </#list>
+  <#-- one last check for a multi-resp table left open before moving on, will happen if last question was in a multi-resp -->
+    <#if haveOpenMultiRespHeader>
+          </table>
+        </td>
+      </tr>
+    </#if>
   <tr>
     <td>&nbsp;</td>
     <td>&nbsp;</td>