Display a form submit button.
When clicked, all widget values inside the form will be sent from the user's browser to the Jeamlit server in a batch.
Every form must have at least one Jt.formSubmitButton
. A Jt.formSubmitButton
cannot exist outside a form.
Method Signatures and Parameters | |
Jt.formSubmitButton(String label) | label (String) The text to display on the submit button |
Chainable builder methods | |
type(String type) | The button type that determines its appearance and emphasis level. Can be |
icon(String icon) | An icon to display with the error message. The following values are valid:
null (default), no icon is displayed.
|
help(String help) | A tooltip that gets displayed next to the text. If this is |
disabled(boolean disabled) | Disables the button if set to True. When disabled, users cannot interact with the widget. |
useContainerWidth(boolean useContainerWidth) | Controls the button width. If True, the button width matches the parent container width. If False (default), the button width matches its content width. This parameter is deprecated - use width() instead. |
onClick(function.Consumer<Boolean> onClick) | An optional callable function that is invoked when the button is clicked.
The callback receives the previous button click state as a parameter. In this case, the previous click state is always |
key(String key) | A string to use as the unique key for the widget. If this is omitted, a key will be generated for the widget based on its content. No two widgets may have the same key. |
No description | |
use() | Put the widget in the app, in the |
use(JtContainer container) | Put the widget in the app, in the provided container. |
Returns after .use() | |
(boolean) | The current boolean value of the component. |
Examples
Basic form submit button
import tech.catheu.jeamlit.core.Jt;
public class FormSubmitApp {
public static void main(String[] args) {
var form = Jt.form("contact").use();
String name = Jt.textInput("Your Name").use(form);
String message = Jt.textArea("Message").use(form);
if (Jt.formSubmitButton("Send Message").use(form)) {
Jt.text("Message sent successfully!").use();
Jt.text("From: " + name).use();
}
}
}
Multiple submit buttons in same form
import tech.catheu.jeamlit.core.Jt;
public class MultiSubmitApp {
public static void main(String[] args) {
var form = Jt.form("document").use();
String title = Jt.textInput("Document Title").use(form);
String content = Jt.textArea("Content").use(form);
if (Jt.formSubmitButton("Save Draft").key("save").use(form)) {
Jt.text("Draft saved: " + title).use();
}
if (Jt.formSubmitButton("Publish").key("publish").use(form)) {
Jt.text("Document published: " + title).use();
}
}
}
Still have questions?
Go to our discussions forum for helpful information and advice from Jeamlit experts.