1

我们在使用JSP自定义表单标签,发现结束标签</form>总是显示在错误的位置,这给我们带来了很多问题,因为用户提交表单后,下面动态生成的html元素没有嵌套在里面<form>...</form>,这些元素数据丢失了. 这是代码:

   <ct:table>
       <ct:form name="form1" >
           <ct:addFromRequest prefix="<%= AP.CSA_PREFIX %>" />
           <ct:add name="<%= AP.ACTION %>" value=" " />
           <tr>
            .....some dynamically generated code here
           </tr>
       </ct:form>
    </ct:table>

在 IE 中,它按预期工作:

  <table>
    <form name="form1" >
    <tr>
    ...
    </tr>
    </form>
   </table>

但在 FireFox 和 Chrome 中,它总是显示如下:

  <table>
    <form name="form1" ></form>  *******the closing </form> tag appears here
    <tr>
    ... dynamically generated html controls here
    </tr>
  </table>

整个页面是代码在这里:

<%
CCtFormValidation ct_form = new CCtFormValidation( jsp_input );
CCtHelperFunctions ct_helper = new CCtHelperFunctions( jsp_input );
%>

<%@ include file="../../generic_gui/template/general_head.jsp" %>
<ct:script>
function CheckForm ( form_to_check )
{
    if ( form_to_check.<%=AP.MANAGE_GROUP%>[0].checked 
        && form_to_check.<%=AP.GROUP_ID%>.selectedIndex < 1 )
    {
        <%= ct_form.printErrorJavascriptAlert ( CFrontEndErrorCodes.FRONTEND_ERROR_CODE_MISSING_MANDATORY_PARAMS ) %>
        form_to_check.<%=AP.GROUP_ID%>.focus();
        return false;
    }
    return true;
}
function BeforeSubmit( form_to_submit )
{
    form_to_submit.<%=AP.ACTION%>.value = "<%=AP.ACTION_SUBMIT%>";
}

function BeforeCancel( form_to_cancel )
{
    form_to_cancel.<%=AP.ACTION%>.value = "<%=AP.ACTION_CANCEL%>";
}

function OnLoad()
{
}

</ct:script>


<%@ include file="../../generic_gui/template/general_body_start.jsp" %>
<ct:table width="75%">
    <tr>
        <td>
            <ct:form name="form1">
            <ct:addFromRequest prefix="<%= AP.CSA_PREFIX %>" />
            <ct:add name="<%= AP.ACTION %>" value=" " />
            <span class="PageHeader">
                <%= rc.getStr ( "s_page_title" ) %>
            </span>
        </td>
    </tr>
    <tr>
        <td colspan="3"><br><br></td> 
    </tr>
    <tr>
        <td colspan="3">
            <span class="BodyText">
                <%= rc.getStr ( "s_text_1" ) %>
            </span>
        </td>
    </tr>
    <tr>
        <td colspan="3"><br></td> 
    </tr>
    <tr>
        <td colspan="2">
            <input type="radio" name="<%=AP.MANAGE_GROUP%>" value="<%=AP.MODIFY_GROUP%>" checked>
            &nbsp;
            <span class="BodyText">
                <%= rc.getStr("s_modify_group_text")%>
            </span>
        </td>
        <td>
            <span class="BodyText">
                <select id="<%=AP.GROUP_ID%>" name="<%=AP.GROUP_ID%>" size="1" class="textBoxNoSize" onFocus="document.form1.<%=AP.MANAGE_GROUP%>[0].checked=true;">
                    <OPTION value="<%=rc.getStr("s_select_group")%>"><%=rc.getStr("s_select_group")%></OPTION>
                <%
                    CCSAGroupDetails current_group;
                    for ( int counter = 0 ; counter < group_list.size() ; ++counter )
                    {
                        current_group = ( CCSAGroupDetails ) group_list.get ( counter );
                    %>
                    <OPTION value="<%=current_group.getGroupId()%>"><%=current_group.getGroupName()%></OPTION>
                <% } %>
                </select>
            </span>
        </td>
    </tr>
    <tr>
        <td colspan="3">
            <input type="radio" name="<%=AP.MANAGE_GROUP%>" value = "<%=AP.CREATE_GROUP%>">
            &nbsp;
            <span class="BodyText">
                <%= rc.getStr("s_create_group_text")%>
            </span>
        </td>
    </tr>
    <tr>
        <td colspan="3">
        <br>
        </td>
    </tr>
    <tr height="50" valign="bottom">
        <td align="center">
            <ct:button param="button_next" javascript="SubmitForm( document.form1 );"/></td>
        <td></td>
        <td align="center">
            <ct:button param="button_cancel" javascript="CancelForm( document.form1 );"/></td>
    </tr>
</ct:form>
</ct:table>
<%@ include file="../../generic_gui/template/general_body_end.jsp" %>
<%@ include file="../../generic_gui/template/general_footer.jsp" %>

在 IE 上呈现的页面带有右标记开始和关闭<form name=form1>...</form>,但是 FF 和 Chrome 页面呈现为<form name=form1></form>.

我的代码有问题吗?

4

0 回答 0