0

必要に応じて PVCS (バージョン マネージャー) Web バージョンを変更しようとしています。この商品はJSPで書きました。私の問題は、単純なコンボボックスを追加すると、以下のエラーが表示され、理由がわかりません?! コードをデバッグしましたが、何が問題なのかわかりませんでした。問題の解決を手伝ってください。

ダイアログ.jsp

Line: 281
Error: 'elements[...].value' is null or not an object

エラーを受け取った関数: 見つけてください: alert(name + " -a- "+ targetForm.elements[name].value)

/* copy form data from one form to another */
function copyFormData(targetForm, sourceForm)
{
    for (var i = 0; i < sourceForm.elements.length; i++) {
        element = sourceForm.elements[i]
        type = sourceForm.elements[i].type
        if (type == "text" || type == "textarea" || type == "password") {
            name = sourceForm.elements[i].name

            zField = eval("targetForm['"+ name+"']");
            if ( validElement( zField ) )               
                targetForm.elements[name].value = sourceForm.elements[i].value
        }
        else if (type == "checkbox") {
            name = sourceForm.elements[i].name
            if (sourceForm.elements[i].checked)
                targetForm.elements[name].value = sourceForm.elements[i].value
        }
        else if (type == "radio") {
            name = sourceForm.elements[i].name
            if (sourceForm.elements[i].checked)
                targetForm.elements[name].value = sourceForm.elements[i].value
        }
        else if (type == "select-one") {
            name = sourceForm.elements[i].name
            selectedIndex = sourceForm.elements[i].selectedIndex
            alert(name  + " -a- "+ targetForm.elements[name].value)

            if (sourceForm.elements[i].options[selectedIndex].value != "")
                targetForm.elements[name].value = sourceForm.elements[i].options[selectedIndex].value
            else
                targetForm.elements[name].value = sourceForm.elements[i].options[selectedIndex].text
        }
        else if (type == "select-multiple") {
            // FIXME_CWP - this code only handles the first selection from
            // a selection of type select-multiple.  Currently, there are
            // no cases where this is used.  Before multiple selections
            // are properly handled, a suitable delimiter must be decided
            // upon.
            // The main reason this was done was because Netscape interprets
            // a select box of size > 1 as a select-multiple
            name = sourceForm.elements[i].name
            selection = sourceForm.elements[i].options;

            selectedIndex = -1;
            for (var j = 0; j < selection.length; j++) {
                if (selection[j].selected) {
                    selectedIndex = j;
                    break;
                }
            }

            if (sourceForm.elements[i].options[selectedIndex].value != "")
                targetForm.elements[name].value = sourceForm.elements[i].options[selectedIndex].value
            else
                targetForm.elements[name].value = sourceForm.elements[i].options[selectedIndex].text

            //alert("selectedIndex: " + selectedIndex + "\n" + targetForm.elements[name].value);
        }
    }
}

チェックアウト.jsp -> このファイルの次の行:

copyFormData(masterForm, tabForm);

masterForm が null であるため、エラーが発生するのはなぜですか? コンボボックスなしでページが正常に機能するため。

/* submit master form using elements from other forms */
function onSubmit(masterForm)
{
    // Get the check out location value.
    /*
    if (isNetscape)
        masterForm.<%=options.WORKING_FOLDER%>.value = document.general_layer.document.applets[0].getEditFieldContents();
    else
        masterForm.<%=options.WORKING_FOLDER%>.value = document.applets[0].getEditFieldContents();
    */
    //alert('Check out location=' + masterForm.<%=options.WORKING_FOLDER%>);

    // Copy the fields from the General form
    tabForm = getForm("general_form", "general_layer")
        <%-- START Added by Vamsi on 21st May 2003
    This is done as part of the Vm_secondary_performance_functional_spec
--%>
    if(tabForm.<%=options.CHECKOUT_BY_DATE_RADIO_CHOICE%>.checked)
    {
        advTabForm = getForm("advanced_form", "advanced_layer");
        advTabForm.<%=options.CHECKOUT_BY_DATE%>.checked = 1;
    }
<%-- END Added by Vamsi on 21st May 2003 --%>
    copyFormData(masterForm, tabForm);

    // Get the workfile options index from the general form and set
    // as correct value in the master form.  Note that the index numbers in
    // the switch statement correspond to the order of the select options in the form.
    selectedIndex = tabForm.<%=options.OVERWRITE_WORKITEM%>.selectedIndex;
    switch (selectedIndex)
    {
        case 0:
            masterForm.<%=options.OVERWRITE_WORKITEM%>.value = <%=pvcs.cmd.PvcsConst.PROMPT_USER%>
            break;

        case 1:
            masterForm.<%=options.OVERWRITE_WORKITEM%>.value = <%=pvcs.cmd.PvcsConst.ANSWER_YES%>
            break;

        case 2:
            masterForm.<%=options.OVERWRITE_WORKITEM%>.value = <%=pvcs.cmd.PvcsConst.ANSWER_NO%>
            break;

        default:
            alert('Bad selected index for OVERWRITE_WORKITEM: ' + selectedIndex);
    }
    if(<%=isModelInAffect%>){
        if (document.general_form.ENABLE_LOOKUP.checked==false){
            masterForm.<%=options.LOOKUP_REVISION%>.value = "<%=pvcs.cmd.PvcsConst.NOLOOKUP%>";
        }
    }
    else{
        masterForm.<%=options.LOOKUP_REVISION%>.value = "<%=pvcs.cmd.PvcsConst.REVISION%>";
    }   
    // Copy the fields from the Advanced form
    tabForm = getForm("advanced_form", "advanced_layer")

    copyFormData(masterForm, tabForm);
    // Encode form data using UTF8.
    encodeFormData(masterForm, document.UTF8Encode);
    return true;
}

checkout.jsp 変更部分: 以下のコードを追加した後、上記のエラーが表示されます。削除すると正常に動作します!!!!!

<tr>
  <td>Project:</td>
    <td>  
      <select id="projn" name="projn">
          <option value="volvo">Volvo</option>
          <option value="saab" SELECTED>Saab</option>
          <option value="mercedes">Mercedes</option>
          <option value="audi">Audi</option>
        </select> 
    </td>
</tr>

コードの一部

<DIV ID="general_layer" class="visiblelayer" ALIGN="left"><!-- general layer-->
<FORM NAME="general_form" METHOD="post" ACTION="" onSubmit="return genSubmit(this)">
 <BR>
  <TABLE BORDER="0">
   <TR VALIGN="top">
    <TD><%=I18n.getStr(jspFileName,"CHECK_OUT_TO","Check Out To:")%></TD>
    <%-- <TD><INPUT TYPE="text" NAME="<%=options.WORKING_FOLDER%>" VALUE="<%=options.getStringPropertySafe(options.WORKING_FOLDER)%>" SIZE="40" MAXLENGTH="254">&nbsp;<INPUT TYPE="button" VALUE=" ... "></TD> --%>
    <TD><%=HtmlTagHelper.writeBrowseTag("general_form",
                                        options.WORKING_FOLDER,
                                        options.getStringPropertySafe(options.WORKING_FOLDER),
                                        I18n.getStr(jspFileName, "BROWSE_TITLE_KEY", "Select Workfile Location"),
                                        browseType,
                                        45)%>
    </TD>
   </TR>

<%if (projectSelection || multiSelect)
{%>
   <TR VALIGN="top">
    <TD></TD>
    <TD><INPUT TYPE="checkbox" NAME="<%=options.USE_WORKPATH_ATTRIBUTE%>" VALUE="false"><%=I18n.getStr(jspFileName,"CHECK_OUT_USING_PROJECT_HIERARCHY",
                                                                                        "Check out using project hierarchy instead of workfile location(s)")%></TD>
   </TR>
<%}%>
<tr>
    <td>Project:</td>
    <td>  
        <select id="projn" name="projn">
          <option value="volvo">Volvo</option>
          <option value="saab" SELECTED>Saab</option>
          <option value="mercedes">Mercedes</option>
          <option value="audi">Audi</option>
        </select> 
    </td>
</tr>
<tr>
    <td>Developer:</td>
    <td>col2</td>
</tr>
<tr>
    <td>Required Duration:</td>
    <td><input type="text" ID="ReqDuration" name="ReqDuration" value="5"/>Days</td>
</tr>
<tr>
    <td>RFA No:</td>
    <td><input type="text" ID="RFANO"  name="RFANO" value="10256"/></td>
</tr>
<tr>
    <td>Prefered checkout location:</td>
    <td><input type="text" ID="LocationPreFix" name="LocationPreFix" value="C:\projects\"/>
        <input type="button" value="Generate Checkout Link" onClick="generateCheckout()" /></td>
</tr>
   <TR VALIGN="top">
    <TD><%=I18n.getStr(jspFileName,"CHECKOUT_REVISION","Revision:")%></TD>
    <TD><INPUT TYPE="text" NAME="<%=options.REVISION%>" VALUE="<%=revision%>" SIZE="20" MAXLENGTH="254" onChange="revisionChanged()">
    <input type="button" value=" ... " onClick="window.opener.parent.browseForLabel(document.master_form,document.general_form.<%=options.REVISION%>,false,true,'<%=pvcs.vm.servlet.BrowseLabelFrameJspHelper.REVISION_VIEW%>');" onFocus="checkRevision();"/>
    </TD>

   </TR>

   <TR VALIGN="top">
    <TD><%=I18n.getStr(jspFileName,"IF_WORKFILE_EXISTS","If&nbsp;Workfile&nbsp;Exists:")%></TD>
    <TD>
     <SELECT name="<%=options.OVERWRITE_WORKITEM%>">
      <OPTION <%if (overWriteWorkItem == pvcs.cmd.PvcsConst.PROMPT_USER) {%> SELECTED <%}%>><%=I18n.getStr(jspFileName,"IF_EXISTS_PROMPT","Prompt")%>
      <OPTION <%if (overWriteWorkItem == pvcs.cmd.PvcsConst.ANSWER_YES) {%> SELECTED <%}%>><%=I18n.getStr(jspFileName,"IF_EXISTS_OVERWRITE","Overwrite")%>
      <OPTION <%if (overWriteWorkItem == pvcs.cmd.PvcsConst.ANSWER_NO) {%> SELECTED <%}%>><%=I18n.getStr(jspFileName,"IF_EXISTS_DONT_OVERWRITE","Do not overwrite")%>
      </SELECT>
     </TD>
   </TR>
<%  
    if (devPromoGroups != null)
    {
%>
   <TR VALIGN="top">
    <TD><%=I18n.getStr(jspFileName,"CHECKOUT_PROMOTION_GROUP","Promotion&nbsp;Group:")%></TD>
    <TD>
     <SELECT name="<%=options.TO_PROMOTION_GROUP%>">
<%      for (int i=0; i < devPromoGroups.length; i++)
        {
%>
            <OPTION><%=devPromoGroups[i]%>
<%      }%>
      </SELECT>
    </TD>
   </TR>
<%  }%>
<%if (showAssociationsButton)
{%>
 <tr>
  <td>
   <br>
   <INPUT TYPE="button" VALUE="<%=I18n.getStr(jspFileName,"AssociateSCRS","Associate Issues")%>" onClick="onAssociateSCRs()">
  </td>
 </tr>
<% }%>
<%-- START Added by Vamsi on 22nd May 2003
    This is done as part of the Vm_secondary_performance_functional_spec. The below code is
    moved from the Advanced Tab.
--%>
   <TR VALIGN="top">
    <TD  COLSPAN="3">
     <INPUT TYPE="checkbox" NAME="<%=options.CHECKOUT_BY_DATE_RADIO_CHOICE%>" <%if (options.getBooleanPropertySafe(options.ONLY_IF_REVISION_NEWER, false)) {%> CHECKED <%}%> VALUE="<%=options.CHECKOUT_BY_DATE_RADIO_ONLY_IF_REVISION_NEWER%>"><%=I18n.getStr(jspFileName,"GET_REVISION_NEWER_THAN_WORK_FILE","Get only if revision newer than workfile")%>
    </TD>
   </TR>
    <%  
    if (devPromoGroups != null )
    {
   %>
   <TR VALIGN="top">
    <TD  COLSPAN="3">
         <input type="checkbox" NAME="ENABLE_LOOKUP" <%if (!disableLookup) {%> CHECKED <%}%> onClick="toggleLookupOptions();"><%=I18n.getStr(jspFileName,"LOOKUP_ENABLE_LABEL","Force revision lookup")%><br>   
    </TD>
    </TR>   
    <TR VALIGN="top">
    <TD  COLSPAN="3">
     &nbsp;&nbsp;&nbsp;<input type="radio" name="<%=options.LOOKUP_REVISION%>" value="<%=pvcs.cmd.PvcsConst.REVISION%>" <%if (!lookupByGroup) {%> CHECKED <%}%> <%if (disableLookup) {%> DISABLED <%}%>> <%=I18n.getStr(jspFileName,"LOOKUP_REV_LABEL","Based on Revision")%><br>
     &nbsp;&nbsp;&nbsp;<input type="radio" name="<%=options.LOOKUP_REVISION%>" value="<%=pvcs.cmd.PvcsConst.GROUP%>" <%if (lookupByGroup) {%> CHECKED <%}%> <%if (disableLookup) {%> DISABLED <%}%>> <%=I18n.getStr(jspFileName,"LOOKUP_GROUP_LABEL","Based on Promotion Group")%>       
    </TD>
   </TR>
   <%}%>
<%-- END --%>
 </TABLE>
 <BR>
</FORM>
</DIV>
4

1 に答える 1

0

そのページには、「copyFormData」関数がすべてのフィールドのコピーを取得してそこに保存する隠しファイルがいくつかあることがわかりました。そのため、新しいフィールドが使用できなかったため、null エラーが発生しました。

于 2013-04-26T04:17:17.890 に答える