Skip to content

Instantly share code, notes, and snippets.

@VaughnVernon
Last active December 16, 2015 05:09
Show Gist options
  • Save VaughnVernon/5382404 to your computer and use it in GitHub Desktop.
Save VaughnVernon/5382404 to your computer and use it in GitHub Desktop.
Shows How Grails Could Take Form Input and Dispatch to Domain Model Aggregate Method
planBacklogItem.gsp
-------------------
<g:form action="product:planBacklogItem" >
<fieldset class="form">
<g:hiddenField name="product:productId" value="${product.productId}"/>
<g:textField name="summary" value=""/>
<g:textField name="story" value=""/>
<g:textField name="storyPoints" value=""/>
...
</fieldset>
<fieldset class="buttons">
<g:submitButton name="planBacklogItem" class="save" value="Plan Backlog Item" />
</fieldset>
Grails Mapping
--------------
Rather than map from form fields to BacklogItem setters, map from form
action/command to given Product's command method and pass form field
values as parameters.
Product.groovy
--------------
BacklogItem planBacklogItem(String summary, String story, String storyPoints, ...) {
BacklogItem backlogItem = new BacklogItem(...);
DomainEventPublisher.instance().publish(new ProductBacklogItemPlanned(...));
return backlogItem;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment