Reputation:
I am creating app in JSF. I want that when I click on submit button, then it should call the same page, but show edit button instead of submit button. How can I do that?
Upvotes: 0
Views: 645
Reputation: 1108557
Let the action method set a boolean property in a @ViewScoped
bean to toggle the buttons and return null
or void
to return to the same view. Let the view conditionally render the submit and edit buttons based on the boolean.
Basically,
private boolean editmode;
public void submit() {
editmode = true;
}
public boolean isEditmode() {
return editmode;
}
With
<h:commandButton value="Submit" action="#{bean.submit}" rendered="#{not bean.editmode}" />
<h:commandButton value="Edit" action="#{bean.edit}" rendered="#{bean.editmode}" />
Unrelated to the concrete question, this is however a quite strange requirement. Shouldn't the "Submit button" in your question actually be an "Edit button" and the "Edit button" in your question actually be a "Save button"? That'd make more sense.
Upvotes: 1