提交表单时,我无法将上下文作为字符串传递给 Tapestry 中的提交事件处理程序。它是怎么做的?
问问题
480 次
1 回答
1
The exception you are seeing is saying that you are not allowed to place the Submit
outside a tapestry Form
. A good way to deal with context on a form submit is to add the context to the Form and pick it up on the prepare for submit event. Like so:
@Component(id = "form", parameters = {"context=myString"})
private Form form
@OnEvent(component="form", value=EventConstants.PREPARE_FOR_SUBMIT)
private void handlePrepare(String contextString) {
.... do what is needed with the contextString ...
}
@OnEvent(component="form", value=EventConstants.SUCCESS)
private Object handlePrepare() {
.... handle form succes ...
return null;
}
public String getMyString() {
return "Some string"
}
Here you can leave the submit button out of the equation. If you do require the submit button, please provide your java code and *.tml markup in the initial question.
Good luck!
于 2012-11-20T08:41:33.060 回答