I am new to tapestry. Can someone help me on following issue I am having hard time solving?
I have a form in my page tags.tml
<div class="tagForm" id="addTagFormElement" style="display:none;">
<t:form t:id="addTagForm" t:zone="tagsZone" class="hideForReadOnlyMode addTagForm" style="display:inline-block;">
<t:textfield t:id="newTag" t:mixins="salsaautocomplete" size="25" placeholder="add a tag" validate="required" value="newTag" />
</t:form>
</div>
When this form is submitted, following method is called on the server side java class tags.java
Object onSuccessFromAddTagForm() {
// some logic
}
I want to know how can I pass a parameter(say "testParameter") from tml file to this method which is invoked when the form is submitted. I would like to do something like below.
<div class="tagForm" id="addTagFormElement" style="display:none;">
<t:form t:id="addTagForm" t:zone="tagsZone" t:testParameter="testValue" class="hideForReadOnlyMode addTagForm" style="display:inline-block;">
<t:textfield t:id="newTag" t:mixins="salsaautocomplete" size="25" placeholder="add a tag" validate="required" value="newTag" />
</t:form>
</div>
And access it in method like,
Object onSuccessFromAddTagForm(String testParameter) {
// some logic
}
Use context
parameter of form . You can pass a single parameter or multiple parameters (using context='[param1, param2]'
) and then in the submit handler you can use
Object onSubmitFromMyForm(Object param1, Object param2){
....
}
Please note, the parameters are type coerced.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.