javascript - Aria Templates - Form Submission Issues -
i trying submit aria template form http://ariatemplates.com/,the submission done spring mvc controller/servlet.
the form getting submitted right not able values of aria elements date picker,text box etc in controller. request.getparameter
of no use.
any appreciated.
here sample tpl file,js file , spring controller.
tpl file
{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, : 'value' } } }/} <br /> {/@aria:div} <br /> {@aria:iconbutton { icon: "std:confirm", label:"create", width : 300, tooltip : "click on create report", block: true, onclick : { fn : buttonclick } } /} </div> </form> {/macro} {/template}
javascript file :
aria.tplscriptdefinition({ $classpath : "view.turnoverscript", $prototype : { /** * callback click event on 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 : } }); }, 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 error"); } } });
in aria templates don't work dom elements data model.
the way achieve want bind values datamodel using bind
property
{@aria:datepicker { label: " begin date:", labelwidth:190, width:330, helptext:"type date or select", bind : { value : { inside : data, : "begin_date" } } }/}
your datamodel contain values, try modify values , see content of this.data
in template script.
to submit data have 2 options,
template script through aria.core.io.asyncrequest (or maybe requestmgr, depending on application complexity). method takes
data
string in case ofpost
requests message body. has string can usearia.utils.json.jsonserializer.serialize()
convert datamodel string.aria.utils.json.jsonserializer.serialize(this.data, config)
in previous snippet of code config
optional, if provided should match bean.
- module controller through submitjsonrequest thing using controller separate logic of connecting server template , can send directly object data, serialization done internally. drawback you'll have configure urlservice convert actions actual url. few more info here
Comments
Post a Comment