未捕获的ReferenceError:使用c:forEach在Jsp中没有定义[function]?

时间:2016-10-07 04:20:18

标签: javascript jquery html jsp

我正在开发一个使用struts的web应用程序,当我在我的系统上尝试当前正在开发的代码时,它的工作正常但是当我在实时服务器上部署时它不调用Javascript函数,它也使用c:forEach在其中。 我不知道我做错了什么,我知道关于这个问题有很多问题,但是我尝试了一切,但是没有一个适用于我的场景。这是我的Jsp文件。

<body>
<logic:equal name="menu" value="package">
                                    <h2><span>Packages</span></h2>
                                    <span class="dropdown place">
                                        <a class="dd_btn" href="javascript:void(0);" >Action</a>
                                        <ul class="subdrop">
                                            <li><a onclick="display('addPackDiv')" href="javascript:void(0);">Create New</a></li>
                                            <li><a onclick="setPackage();" href="javascript:void(0);">Edit</a></li>
                                            <li><a onclick="return delPackage();" href="javascript:void(0);">Delete</a></li>
                                            <li><a onclick="return exportPackages();" href="javascript:void(0);">Export</a></li>
                                            <li><a onclick="return featurePackages('feature');" href="javascript:void(0);">Feature</a></li>
                                            <li><a onclick="return featurePackages('unfeature');" href="javascript:void(0);">UnFeature</a></li>

                                        </ul>
                                    </span>
                                </logic:equal>
<script type="text/javascript">
function setPackage(){
                alert("in setpackage");
                var ids = "";
                var chbxs = document.forms[0].actionCheckBox;
                if (chbxs.length != undefined) {
                    for (i = 0; i < chbxs.length; i++)
                    {
                        if (chbxs[i].type == 'checkbox' && chbxs[i].checked)
                        {
                            var cname = chbxs[i].value;
                            if (!cname)
                                continue;
                            if (ids == "")
                                ids = cname;
                            else
                                ids += "," + cname + "";

                        }
                    }

                    if (ids == null || ids == "") {
                        jAlert("Please select one item to edit");
                        return;
                    }

                    if (ids.split(",").length > 1) {
                        jAlert("Select only one item to edit.");
                        return;
                    }
                } else {  //If Not Node List.
                    try {
                        ids = chbxs.value;
                    } catch (err) {
                    }
                }

                //alert("step 1 "+ids);
            /* collection reset */
                document.getElementById('updateCollection').innerHTML = '';
                var updateCollectionSel = document.getElementById('updateCollectionSel');
                updateCollectionSel.innerHTML = '';
                var innCollectionHtml = '';
         <c:forEach var="CollectionDTO" items="${requestScope.allCollectionList}">
          innCollectionHtml += "<option value='${CollectionDTO.collectionId}'>${CollectionDTO.collectionName}</option>";
        </c:forEach>
            updateCollectionSel.innerHTML = innCollectionHtml;
            //alert("innCollectionHtml "+innCollectionHtml);

                //END

              //alert("step 2");
              /* program reset */
                document.getElementById('updateProgram').innerHTML = '';
                var updateProgramSel = document.getElementById('updateProgramSel');
                updateProgramSel.innerHTML = '';
                var innProHtml ='';
               <c:forEach var="ProgramDTO" items="${requestScope.allProgramList}">
                innProHtml += "<option value='${ProgramDTO.programid}'>${ProgramDTO.name}</option>";
               </c:forEach>
                 updateProgramSel.innerHTML =   innProHtml; 
                 //alert("innProHtml "+innProHtml);
                //END

                // alert("step 3");

                /* channel reset */
                document.getElementById('updateChannel').innerHTML = '';
                var updateChannelSel = document.getElementById('updateChannelSel');
                updateChannelSel.innerHTML = '';
                var innChannelHtml = '';
        <c:forEach var="SMSChannelDTO" items="${requestScope.allChannelList}">
           innChannelHtml += "<option value='${SMSChannelDTO.channelId}'>${SMSChannelDTO.name}</option>";
        </c:forEach>
            updateChannelSel.innerHTML = innChannelHtml;
             //alert("innChannelHtml "+innChannelHtml);

                //END

               //alert("step 4");
                 var packageId = ids;
                var server = '<%= request.getServerName()%>';
                if (server == 'localhost') {
                    server = server + ":" + '<%= request.getServerPort()%>';
                }
                       <c:forEach var="packageDTO" items="${requestScope.packageList}">
                    if (packageId == '${packageDTO.packageId}') {

                         <c:forEach var="DistributorDTO" items="${requestScope.displayDistributor}">
                         var allDistName1=  '${DistributorDTO.email_id}';
                             document.getElementById(allDistName1).checked = false;
                              document.getElementById("prepaidprice"+allDistName1).value='0.0';
                              document.getElementById("postpaidprice"+allDistName1).value='0.0';
                     </c:forEach>

                        document.getElementById('updatePackageName').value = '${packageDTO.name}';
                        document.getElementById('updatePackageImg1').value = '${packageDTO.image}'
                        document.getElementById('updatefeaturedImage').value = '${packageDTO.featuredImage}';
            <%--document.getElementById('packImg').src = 'http://'+server+'/SMS/'+'${packageDTO.image}';--%>
                        /* refill remaining channel list */
                        var packagesChannelIdArr = new Array(${fn:length(packageDTO.channelList)});
                        var i = 0;
                        <c:forEach var="SMSChannelDTO" items="${packageDTO.channelList}">
                            packagesChannelIdArr[i] = '${SMSChannelDTO.channelId}';
                            i++;
            </c:forEach>
                        setChannels(packagesChannelIdArr);
                        //END

                        /* refill remaining program list */
                        var packagesEventIdArr = new Array(${fn:length(packageDTO.programList)});
                        var j = 0;
                <c:forEach var="ProgramDTO" items="${packageDTO.programList}">
                            packagesEventIdArr[j] = '${ProgramDTO.programid}';
                            j++;
            </c:forEach>
                        setPrograms(packagesEventIdArr);
                        //END

                        /* refill remaining collection list */
                        var packagesCollectionIdArr = new Array(${fn:length(packageDTO.collectionList)});
                        var k = 0;
                <c:forEach var="CollectionDTO" items="${packageDTO.collectionList}">
                            packagesCollectionIdArr[k] = '${CollectionDTO.collectionId}';
                            k++;
            </c:forEach>
                        setCollection(packagesCollectionIdArr);
                        //END
                        /* fill programs */
                        var x = document.getElementById('updateProgram');
                <c:forEach var="ProgramDTO" items="${packageDTO.programList}">
                            x.innerHTML += "<option value='${ProgramDTO.programid}'>${ProgramDTO.name}</option>";
            </c:forEach>
                        //END

                        /* fill channels */
                        var y = document.getElementById('updateChannel');
                <c:forEach var="SMSChannelDTO" items="${packageDTO.channelList}">
                            y.innerHTML += "<option value='${SMSChannelDTO.channelId}'>${SMSChannelDTO.name}</option>";
            </c:forEach>
                        //END

                        /* fill collection */
                        var z = document.getElementById('updateCollection');
                <c:forEach var="CollectionDTO" items="${packageDTO.collectionList}">
                            z.innerHTML += "<option value='${CollectionDTO.collectionId}'>${CollectionDTO.collectionName}</option>";
            </c:forEach>
                        //END

            <c:forEach var="DistributorDTO" items="${requestScope.displayDistributor}">
                 var allDistName=  '${DistributorDTO.email_id}';
                     <c:forEach var="DistributorDTO" items="${packageDTO.distributorListForPack}">
                            var packdist='${DistributorDTO.email_id}';
                            if(allDistName === packdist){
                              document.getElementById("prepaidprice"+packdist).value='${DistributorDTO.prepaidprice}';
                              document.getElementById("postpaidprice"+packdist).value='${DistributorDTO.postpaidprice}';
                             document.getElementById(packdist).checked = true;
                            }

                     </c:forEach>
             </c:forEach>
                        document.getElementById('updateDescription').value = "${packageDTO.description}";
                        document.getElementById('packImgName').value = '${packageDTO.image}';
                        document.getElementById('updatePackageImg1').style.display = 'inline';
                        document.getElementById('updatePrice').value = '${packageDTO.subscriptionPrice}';
                        document.getElementById('updateCurrency').value = '${packageDTO.priceUnit}';
                        document.getElementById('updateSubscriptionPeriod').value = '${packageDTO.subscriptionPeriod}';
                       var distributorType= '${packageDTO.distributorType}';
                        if(distributorType === "List distributors"){
                            document.getElementById('edit_pack_dist_dropdown').value ="List distributorsdisp";

                        }else{
                             document.getElementById('edit_pack_dist_dropdown').value = '${packageDTO.distributorType}';
                             }

                        document.getElementById('updatePostpaidPrice').value = '${packageDTO.updatePostpaidPrice}';
                        document.getElementById('updatePostPaidCurrency').value = '${packageDTO.updatePostPaidCurrency}';


                        document.getElementById('updateUnit').value = '${packageDTO.periodUnit}';
                        display('editPackDiv');
            <%-- document.getElementById('updateFeatured').checked = <c:if test="${packageDTO.featured == 1}">true</c:if><c:if test="${packageDTO.featured == 0}">false</c:if>;  --%>
                    } else if (packageId == '' || packageId == 'Select') {
                        document.getElementById('updatePackageName').value = '';
                        document.getElementById('packImgName').value = '';
                        document.getElementById('updatePackageImg1').style.display = 'none';
                        document.getElementById('updateDescription').value = '';
                        deselectChannelIds();
                        document.getElementById('packImg').src = '';
                        document.getElementById('updatePrice').value = '';
                        document.getElementById('updateCurrency').value = 'INR';
                        document.getElementById('updateSubscriptionPeriod').value = '';

                        document.getElementById('edit_pack_dist_dropdown').value =  '';

                        document.getElementById('updatePostpaidPrice').value =  '';
                        document.getElementById('updatePostPaidCurrency').value = '';

                        document.getElementById('updateUnit').value = 'day';
                        //document.getElementById('updateFeatured').checked = false;
                    }
        </c:forEach>
        return false;



          }

    

我得到Uncaught ReferenceError:chrome Console中没有定义setPackage()错误。 请帮帮我。

0 个答案:

没有答案