2013-05-09 34 views
1

我想提交一个咏叹调模板表格http://ariatemplates.com/,提交到Spring MVC控制器/ servlet。咏叹调模板 - 表单提交问题

表单正在提交所有权利,但我无法获取控制器中的日期选择器,文本框等咏叹调元素的值。 Request.getParameter是没用的。

任何帮助将不胜感激。

这是我的示例tpl文件,js文件和Spring控制器。

TPL文件

{Template { 
    $classpath:'view.Turnover', 
    $hasScript : true 
}} 
    {macro main()} 
    <form action="test.do" method="POST" id="turnoverform"> 
    <div style="float:left;padding-top: 3em;padding-bottom: 3em;padding-right: 3em;"> 
    {@aria:Div { 
     sclass : "basic", 
     width : 740, 
     height : 300 
     }} 

     <p style="font-family:Arial,Helvetica,sans-serif;font-size: medium;">Create Turnover Report</p> 
     <hr /> 

     {@aria:DatePicker { 
      label: " begin date:", 
      labelWidth:190, 
      width:330, 
      helptext:"Type date or select", 

     }/} 
     {@aria:DatePicker { 
      margins:"x x x 20", 
      label: "end date:", 
      labelWidth:190, 
      helptext:"Type date or select", 
      width:330, 

     }/} 
     <br/> 
     <br/> 
     <br/> 

     {@aria:TextField { 
      label : "User id", 
      labelPos : "left", 
      helptext : "ID", 
      width : 250, 
      block : true, 
      labelWidth : 80, 
      bind : { 
      "value" : { 
       inside : data, 
       to : 'value' } 
      } 
    }/} 
    <br /> 


    {/@aria:Div} 
    <br /> 
    {@aria:IconButton { 
     icon: "std:confirm", 
     label:"Create", 
     width : 300, 
     tooltip : "Click on this to create a Report", 
     block: true, 
     onclick : { 
     fn : buttonClick 
     } 
    } /} 
    </div> 
    </form> 
{/macro} 
{/Template} 

JavaScript文件:

Aria.tplScriptDefinition({ 
    $classpath : "view.TurnoverScript", 
    $prototype : { 
    /** 
    * Callback for the click event on the first button. 
    * @param {aria.DomEvent} evt Click event 
    */ 
    buttonClick : function (evt) { 


     aria.core.IO.asyncFormSubmit({ 
      formId : "turnoverform", 
      callback : { 
      fn : this.onSuccess, 
      onerror : this.onError, 
      scope : this 
      } 
     }); 
    }, 

    onSuccess : function (evt, args) { 


     alert("The Template has been created"); 
     //this.$json.setValue(["view:Dialog"], "dialogOpen", true); 

     }, 



     onError : function (evt, args) { 


      alert("The Template has not been created due to some Error"); 

     } 
    } 
}); 
+0

请问您可以发布代码示例吗?你如何提交? [this](http://ariatemplates.com/usermanual/Form_Submissions)有帮助吗? – dgn 2013-05-13 15:18:49

+0

@scenario已经看过并遵循它,但并没有真正解决我的问题。我附上示例代码以供参考 – 2013-05-14 05:52:47

回答

2

在咏叹调模板,你通常不会与DOM元素,但与数据模型的工作。

达到你想要的东西的方式是使用bind财产

{@aria:DatePicker { 
    label: " begin date:", 
    labelWidth:190, 
    width:330, 
    helptext:"Type date or select", 
    bind : { 
     value : { 
      inside : data, 
      to : "begin_date" 
     } 
    } 
}/} 
这些值绑定到数据模型

你的数据模型将现在包含这些价值观,试图修改这些价值观和看到的this.data在内容你的模板脚本。

要通过aria.core.Io.asyncRequest提交你有两个选择数据,

  • 模板脚本(或者也许是RequestMgr,这取决于你的应用程序的复杂性)。 此方法需要一个data字符串,如果POST请求是消息正文。它必须是一个字符串,因此您可以使用aria.utils.json.JsonSerializer.serialize()将您的数据模型转换为字符串。

    aria.utils.json.JsonSerializer.serialize(this.data,配置)

在代码config先前片段是可选的,如果提供的话,应该匹配此bean

  • 通过submitJsonRequest 有关使用的控制器的好处模块控制器是你分开连接到从模板服务器的逻辑和,作为数据,串行化是在内部完成你可以直接发送的对象。 缺点是,您可能必须配置UrlService才能将操作转换为实际的网址。更多信息here