2012-09-05 31 views
0

Spring WebFlow2 JavaScript没有提交页面?Spring WebFlow2 JavaScript未提交页面?

我想使用WebFlow2附带的Spring JavaScript来提交带有过渡值的页面,如果用户单击其中一个单选按钮。我插入我的JavaScript,但页面没有得到提交点击?

JSP:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> 
<html> 
<head> 
<title>Spring 3.0 MVC - Web Flow Example</title> 

<script type="text/javascript" 
    src="<c:url value="/resources/dojo/dojo.js" />"> 

</script> 
<script type="text/javascript" 
    src="<c:url value="/resources/spring/Spring.js" />"> 

</script> 
<script type="text/javascript" 
    src="<c:url value="/resources/spring/Spring-Dojo.js" />"> 

</script> 

<link type="text/css" rel="stylesheet" 
    href="<c:url value="/resources/dijit/themes/tundra/tundra.css" />" /> 
</head> 
<body> 
    <h2>Customer Registration</h2> 

    <form:form commandName="customer" id="customer"> 
     <input type="hidden" name="_flowExecutionKey" 
      value="${flowExecutionKey}" /> 
     <table> 
      <tr> 
       <td><font color=red><form:errors path="name" /></font><b>Name: 
       </b></td> 
       <td><form:input path="name" id="name" /> <script 
         type="text/javascript"> 
        Spring 
          .addDecoration(new Spring.ElementDecoration(
            { 
             elementId : "name", 
             widgetType : "dijit.form.ValidationTextBox", 
             widgetAttrs : { 
              promptMessage : "This is the name you would like entered into the system." 
             } 
            })); 
       </script> <br /> 
        <p></td> 
      </tr> 
      <tr> 
       <td><font color=red><form:errors path="phoneNumber" /></font> 

        <b>Phone number: </b></td> 
       <td><form:input path="phoneNumber" id="phoneNumber" /><br /> 
        <script type="text/javascript"> 
         Spring 
           .addDecoration(new Spring.ElementDecoration(
             { 
              elementId : "phoneNumber", 
              widgetType : "dijit.form.ValidationTextBox", 
              widgetAttrs : { 
               promptMessage : "This is the phone number for the above name" 
              } 
             })); 
        </script></td> 
      </tr> 
      <tr> 
       <td></td> 
      </tr> 
      <tr> 
       <td><b>Row:</b></td> 
       <td><form:radiobutton value="B" path="row" id="row" />Row: B<BR> 
        <form:radiobutton value="A" path="row" id="row" />Row: A<BR> 
        <script type="text/javascript"> 
         Spring.addDecoration(new Spring.AjaxEventDecoration({ 
          elementId : "row", 
          formId : "customer", 
          event : "onChange", 
          params : { 
           _eventId : "loadSchools", 
           fragments : "body" 
          } 
         })); 
        </script></td> 
      </tr> 
     </table> 
     <input type="submit" name="_eventId_proceed" value="proceed" 
      id="proceed" /> 
     <script type="text/javascript"> 
      Spring.addDecoration(new Spring.ValidateAllDecoration({ 
       elementId : 'proceed', 
       event : 'onclick' 
      })); 
     </script> 
     <input type="submit" name="_eventId_cancel" value="Cancel" /> 
    </form:form> 

</body> 
</html> 

回答

0

这是我的代码是工作(形式被提交)的一部分,它是与选择而不是单选按钮,但相同的想法。当您选择自动提交表单的值和更新值:

<form:form commandName="dateRange"> 
... 
    <select name="fyForDR" id="fyForDR" class='discretFont' style='margin-left:10px;margin-right:10px;'> 
      <option value="" selected='selected'>Fiscal Year</option> 
      <option value="2011" <c:if test="${fyForDR == '2011'}">selected="selected"</c:if> >FY11</option> 
      <option value="2010" <c:if test="${fyForDR == '2010'}">selected="selected"</c:if> >FY10</option> 
      <option value="2009" <c:if test="${fyForDR == '2009'}">selected="selected"</c:if> >FY09</option> 
      <option value="2008" <c:if test="${fyForDR == '2008'}">selected="selected"</c:if> >FY08</option> 
      <option value="2007" <c:if test="${fyForDR == '2007'}">selected="selected"</c:if> >FY07</option> 
      <option value="2006" <c:if test="${fyForDR == '2006'}">selected="selected"</c:if> >FY06</option> 
     </select> 
     <script type="text/javascript"> 
      Spring.addDecoration(new Spring.AjaxEventDecoration({ 
       elementId: "fyForDR", 
       event: "onchange", 
       formId:"dateRange", 
       params: {fragments:"body", _eventId: "setFy"} 
      })); 
     </script> 
... 
</form:form> 

,这里是流程定义的一部分:

<view-state id="dateRangeForm" model="dateRange"> 
... 
    <transition on="setFy" validate="false" > 
       <set name="viewScope.fyForDR" value="requestParameters.fyForDR"/> 
       <evaluate expression="dateRange.setStartDate(dateRangeService.getFyStartDate(viewScope.fyForDR))"></evaluate> 
       <evaluate expression="dateRange.setEndDate(dateRangeService.getFyEndDate(viewScope.fyForDR))"></evaluate> 
    </transition> 
... 
</view-state> 
+0

感谢,但我用的无线电按钮,再次看起来它只适用于第一个单选按钮 – PartyWithJohn

+0

的第一次点击,所以它的工作原理?你是否把onchange和onclick都装上了,两者都装饰得很好? – rptmat57

+0

NOOOO不工作....我把onchange和onclick,它只适用,如果你点击第一个单选按钮.... – PartyWithJohn

0

尝试把不同的ID为每一行是这样的:

<td><form:radiobutton value="B" path="row" id="rowB" />Row: B<BR> 
     <form:radiobutton value="A" path="row" id="rowA" />Row: A<BR> 
     <script type="text/javascript"> 
       Spring.addDecoration(new Spring.AjaxEventDecoration({ 
        elementId : "rowA", 
        formId : "customer", 
        event : "onChange", 
        params : { 
         _eventId : "loadSchools", 
         fragments : "body" 
         } 
       })); 
       Spring.addDecoration(new Spring.AjaxEventDecoration({ 
        elementId : "rowB", 
        formId : "customer", 
        event : "onChange", 
        params : { 
         _eventId : "loadSchools", 
         fragments : "body" 
         } 
       })); 
     </script></td> 
+0

没有工作...... – PartyWithJohn