Last active
December 16, 2015 05:09
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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