I m struggling with it for some time with no results. I want data entered in a form and submitted to be rendered as a new row of a table being on the same page (without the page reload). What I currently have is an item model with several fields,
a controller with saveItem
action:
public static void saveItem(@Valid SoldItem item) {...
以及当然的形式:
<tr class="itemNew">
<td>
<input type="image" id="saveItem" name="&{ Save }" alt="&{ Save }" height="16" src="/public/images/001_06.png" form="itemsTable"/>
<a href="#/cancelEdits"><image id="cancelEdits" src="/public/images/001_05.png" alt="&{ Cancel }" title="&{ Cancel }" height="16"></a>
</td>
<td>
<div class="item">
<input class="itemDesc" type="text" size="30" name="item.item.name" placeholder="&{ item.name }" />
</div>
<div class="item">
<textarea class="itemDesc" rows="2" cols="30" name="item.item.description" placeholder="&{ item.description }" ></textarea>
</div>
</td>
......
附有一些 Java本:
this.post( #/saveItem , function (context) {
var item_def = new Sammy.Object();
context.log( saveItem - params = + this.params);
context.log( saveItem - form_fields = { );
//for ( var item in this.params.keys()) {
var items = this.params.keys(true);
for ( var i = 0; i < items.length; i++) {
var item = items[i];
context.log( item: + item);
if(item.match(/^item./)) {
item_def[ : + item] = this.params[item];
}
}
context.log( } );
context.log( item_def: + item_def);
var action = #{jsAction @Invoices.saveItem(item_def) /};
context.log( action: + action({item: item_def}));
this.partial(action({item: item_def}));
});
后者是Sammy.js
,但似乎与案件无关。 我得到的是nothing。 下面是最后两个记录条目的样本:
[Fri Jun 10 2011 01:30:51] item_def: Sammy.Object: {":item.item.name": aaa,":item.item.description": dsfsd,":item.retailPrice": dsfs,":item.rebate": sdf,":item.quantity": dsf,":item.vatRate": d,":item.notes": ds}
[Fri Jun 10 2011 01:30:51 ] action: /invoices/saveitem
<代码>jsAction的文件没有涉及这一问题,我找不到任何例子,因此请帮助我。