如何在带有grails的常规gsp中创建多个提交按钮?

时间:2011-08-11 04:11:25

标签: grails groovy

我有三个动作,即create,createMonthly,createQuarterly,我只有一个gsp页面,我需要创建三个提交按钮,三个按钮是数据将转到保存动作......

我创建了这样的按钮

<div class="buttons">
  <span class="button"><g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" /></span>
  <br>
  <span class="button"><g:submitButton name="createMonthly" class="save" value="${message(code: 'default.button.createMonthly.label', default: 'Create Monthly')}" /></span>
  <br>
  <span class="button"><g:submitButton name="createQuarterly" class="save" value="${message(code: 'default.button.createQuarterly.label', default: 'Create Quarterly')}" /></span>
</div>

但它在某种意义上说不正常,当我点击它只显示创建动作的任何按钮时,如何从中调用createMonthly和createQuarterly动作,PLZ帮助我......

2 个答案:

答案 0 :(得分:6)

在您的GSP中使用actionSubmit

例如:

<!--'Update' is action, label is 'Some update label'-->
<g:actionSubmit value="Some update label" action="Update" /> 

答案 1 :(得分:1)

正如尼古拉斯所说。使用actionSubmit。您的代码应如下所示。

<div class="buttons">
  <span class="button"><g:actionSubmit action="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" /></span>
  <br>
  <span class="button"><g:actionSubmit action="createMonthly" class="save" value="${message(code: 'default.button.createMonthly.label', default: 'Create Monthly')}" /></span>
  <br>
  <span class="button"><g:actionSubmit action="createQuarterly" class="save" value="${message(code: 'default.button.createQuarterly.label', default: 'Create Quarterly')}" /></span>
</div>