INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. Submits this form to the server. If submitElement is null, then the submission is treated as if it was triggered by JavaScript, and the onsubmit handler will
(final SubmittableElement submitElement)
| 126 | * @param submitElement the element that caused the submit to occur |
| 127 | */ |
| 128 | public void submit(final SubmittableElement submitElement) { |
| 129 | final HtmlPage htmlPage = (HtmlPage) getPage(); |
| 130 | final WebClient webClient = htmlPage.getWebClient(); |
| 131 | |
| 132 | if (webClient.isJavaScriptEnabled()) { |
| 133 | if (submitElement != null) { |
| 134 | isPreventDefault_ = false; |
| 135 | |
| 136 | boolean validate = true; |
| 137 | if (submitElement instanceof HtmlSubmitInput input |
| 138 | && input.isFormNoValidate()) { |
| 139 | validate = false; |
| 140 | } |
| 141 | else if (submitElement instanceof HtmlButton htmlButton) { |
| 142 | if ("submit".equalsIgnoreCase(htmlButton.getType()) |
| 143 | && htmlButton.isFormNoValidate()) { |
| 144 | validate = false; |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | if (validate |
| 149 | && getAttributeDirect(ATTRIBUTE_NOVALIDATE) != ATTRIBUTE_NOT_DEFINED) { |
| 150 | validate = false; |
| 151 | } |
| 152 | |
| 153 | if (validate && !areChildrenValid()) { |
| 154 | return; |
| 155 | } |
| 156 | final ScriptResult scriptResult = fireEvent(new SubmitEvent(this, |
| 157 | ((HtmlElement) submitElement).getScriptableObject())); |
| 158 | if (isPreventDefault_) { |
| 159 | // null means 'nothing executed' |
| 160 | if (scriptResult == null) { |
| 161 | return; |
| 162 | } |
| 163 | return; |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | final String action = getActionAttribute().trim(); |
| 168 | if (StringUtils.startsWithIgnoreCase(action, JavaScriptURLConnection.JAVASCRIPT_PREFIX)) { |
| 169 | htmlPage.executeJavaScript(action, "Form action", getStartLineNumber()); |
| 170 | return; |
| 171 | } |
| 172 | } |
| 173 | else { |
| 174 | if (StringUtils.startsWithIgnoreCase(getActionAttribute(), JavaScriptURLConnection.JAVASCRIPT_PREFIX)) { |
| 175 | // The action is JavaScript but JavaScript isn't enabled. |
| 176 | return; |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | // html5 attribute's support |
| 181 | if (submitElement != null) { |
| 182 | updateHtml5Attributes(submitElement); |
| 183 | } |
| 184 | |
| 185 | // dialog support |