RendererUtils { public boolean isFormSubmitted(FacesContext context, UIForm form) { if (form != null) { String clientId = form.getClientId(context); String formRequestParam = context.getExternalContext().getRequestParameterMap().get(clientId); return isFormValueSubmitted(clientId, formRequestParam); } return false; } protected  RendererUtils(); static RendererUtils getInstance(); void encodeId(FacesContext context, UIComponent component); void encodeId(FacesContext context, UIComponent component, String attribute); void encodeCustomId(FacesContext context, UIComponent component); Object createParameterValue(UIParameter parameter); Map<String, Object> createParametersMap(FacesContext context, UIComponent component); void encodePassThru(FacesContext context, UIComponent component, String defaultHtmlEvent); void encodePassThruWithExclusions(FacesContext context, UIComponent component, String exclusions,
        String defaultHtmlEvent); void encodePassThruWithExclusionsArray(FacesContext context, UIComponent component, String[] exclusions,
        String defaultHtmlEvent); void encodePassThruAttribute(FacesContext context, Map<String, Object> attributes, ResponseWriter writer,
        String attribute); void encodeAttributesFromArray(FacesContext context, UIComponent component, String[] attrs); void encodeAttributes(FacesContext context, UIComponent component, String attrs); void encodeAttribute(FacesContext context, UIComponent component, Object property, String attributeName); void encodeAttribute(FacesContext context, UIComponent component, String attribute); boolean isEmpty(Object o); boolean isBooleanAttribute(UIComponent component, String name); String encodePx(String value); String encodePctOrPx(String value); UIComponent getNestingForm(UIComponent component); @Deprecated UIComponent getNestingForm(FacesContext context, UIComponent component); UIComponent getSubmittedForm(FacesContext facesContext); boolean isFormSubmitted(FacesContext context, UIForm form); void encodeBeginFormIfNessesary(FacesContext context, UIComponent component); void encodeBeginForm(FacesContext context, UIComponent component, ResponseWriter writer, String clientId); void encodeEndFormIfNessesary(FacesContext context, UIComponent component); static void writeState(FacesContext context); void encodeEndForm(FacesContext context, ResponseWriter writer); String getActionUrl(FacesContext facesContext); String clientId(FacesContext context, UIComponent component); void writeScript(FacesContext context, UIComponent component, Object script); String correctForIdReference(String forAttr, UIComponent component); void encodeChildren(FacesContext context, UIComponent component); boolean hasExplicitId(UIComponent component); UIComponent findComponentFor(FacesContext context, UIComponent component, String id); UIComponent findComponentFor(UIComponent component, String id); static final String DUMMY_FORM_ID; }
@Test public void when_isFormSubbmited_is_called_with_form() { initializeRequestParameterMap(new HashMap<String, String>() { { put("form", "form"); } }); UIForm form = mock(UIForm.class); when(form.getClientId(facesContext)).thenReturn("form"); boolean result = utils.isFormSubmitted(facesContext, form); assertTrue(result); }
@Test public void when_isFormSubbmited_is_called_with_form_which_does_not_have_request_parameter_equal_to_its_clientId_then_false_is_returned() { initializeRequestParameterMap(new HashMap<String, String>() { { put("form", ""); } }); UIForm form = mock(UIForm.class); when(form.getClientId(facesContext)).thenReturn("form"); boolean result = utils.isFormSubmitted(facesContext, form); assertFalse(result); }
@Test public void when_isFormSubbmited_is_called_with_form_which_does_not_have_corresponding_request_parameter_then_false_is_returned() { initializeRequestParameterMap(new HashMap<String, String>() { }); UIForm form = mock(UIForm.class); when(form.getClientId(facesContext)).thenReturn("form"); boolean result = utils.isFormSubmitted(facesContext, form); assertFalse(result); }