rax123
rax123

Reputation: 71

How to pass string as context in tapestry 5.3.2 on click of submit

I am not able to pass context as string to my submit event handler in Tapestry while submitting form. How it's done?

Upvotes: 2

Views: 602

Answers (1)

joostschouten
joostschouten

Reputation: 3893

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!

Upvotes: 1

Related Questions