use of jakarta.faces.component.UIForm in project myfaces by apache.
the class HtmlFormRendererBase method decode.
@Override
public void decode(FacesContext facesContext, UIComponent component) {
RendererUtils.checkParamValidity(facesContext, component, UIForm.class);
UIForm htmlForm = (UIForm) component;
Map paramMap = facesContext.getExternalContext().getRequestParameterMap();
// Perf: initialize StringBuilder to maximal lenght used in this renderer, render_response
// method will re-use it without capacity expanding
StringBuilder sb = SharedStringBuilder.get(facesContext, SHARED_STRING_BUILDER, 100);
String submittedValue = (String) paramMap.get(sb.append(component.getClientId(facesContext)).append(HIDDEN_SUBMIT_INPUT_SUFFIX));
if (submittedValue != null && submittedValue.equals(HIDDEN_SUBMIT_INPUT_VALUE)) {
htmlForm.setSubmitted(true);
} else {
htmlForm.setSubmitted(false);
}
ClientBehaviorRendererUtils.decodeClientBehaviors(facesContext, component);
}
use of jakarta.faces.component.UIForm in project myfaces by apache.
the class ViewPoolMyFacesRequestTestCase method testStaticPage1_1.
@Test
public void testStaticPage1_1() throws Exception {
Locale locale = null;
startViewRequest("/staticPage.xhtml");
processLifecycleExecute();
locale = facesContext.getViewRoot().getLocale();
executeBeforeRender(facesContext);
executeBuildViewCycle(facesContext);
// Add a component in order to trigger a dynamic update
UIOutput testComponent = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE);
testComponent.setId("testId");
testComponent.setValue("Some Text");
UIForm form = (UIForm) facesContext.getViewRoot().findComponent("mainForm");
form.getChildren().add(testComponent);
executeViewHandlerRender(facesContext);
executeAfterRender(facesContext);
UIViewRoot root = new UIViewRoot();
root.setLocale(locale);
root.setRenderKitId("HTML_BASIC");
root.setViewId("/staticPage.xhtml");
ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
ViewPool viewPool = processor.getViewPool(facesContext, root);
ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
Assert.assertNotNull(entry);
Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
// Check the component was removed
UIForm form2 = (UIForm) entry.getViewRoot().findComponent("mainForm");
Assert.assertNotNull(form2);
UIOutput testComponent2 = (UIOutput) form2.findComponent("testId");
Assert.assertNull(testComponent2);
endRequest();
}
use of jakarta.faces.component.UIForm in project myfaces by apache.
the class ViewPoolMyFacesRequestTestCase method testDynamicPage1_1.
@Test
public void testDynamicPage1_1() throws Exception {
Locale locale = null;
startViewRequest("/dynPage1.xhtml");
processLifecycleExecute();
locale = facesContext.getViewRoot().getLocale();
executeBeforeRender(facesContext);
executeBuildViewCycle(facesContext);
// Add a component in order to trigger a dynamic update
UIOutput testComponent = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE);
testComponent.setId("testId");
testComponent.setValue("Some Text");
UIForm form = (UIForm) facesContext.getViewRoot().findComponent("mainForm");
form.getChildren().add(testComponent);
FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get(ComponentSupport.FACELET_STATE_INSTANCE);
executeViewHandlerRender(facesContext);
executeAfterRender(facesContext);
UIViewRoot root = new UIViewRoot();
root.setLocale(locale);
root.setRenderKitId("HTML_BASIC");
root.setViewId("/dynPage1.xhtml");
ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
ViewPool viewPool = processor.getViewPool(facesContext, root);
ViewEntry entry = viewPool.popDynamicStructureView(facesContext, root, faceletState);
Assert.assertNotNull(entry);
Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
// Check the component was removed
UIForm form2 = (UIForm) entry.getViewRoot().findComponent("mainForm");
Assert.assertNotNull(form2);
UIOutput testComponent2 = (UIOutput) form2.findComponent("testId");
Assert.assertNull(testComponent2);
endRequest();
}
use of jakarta.faces.component.UIForm in project myfaces by apache.
the class ViewPoolMyFacesRequestTestCase method testStaticPage1_4.
@Test
public void testStaticPage1_4() throws Exception {
Locale locale = null;
startViewRequest("/staticPage.xhtml");
processLifecycleExecute();
locale = facesContext.getViewRoot().getLocale();
executeBeforeRender(facesContext);
executeBuildViewCycle(facesContext);
// Now let's try to remove some component programatically
// that invalidates the view to be reused without a refresh,
// so in the pool it should be marked as REFRESH_REQUIRED
UIForm form = (UIForm) facesContext.getViewRoot().findComponent("mainForm");
UIComponent panel = form.getChildren().remove(0);
// Add it again
form.getChildren().add(panel);
executeViewHandlerRender(facesContext);
executeAfterRender(facesContext);
UIViewRoot root = new UIViewRoot();
root.setLocale(locale);
root.setRenderKitId("HTML_BASIC");
root.setViewId("/staticPage.xhtml");
ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
ViewPool viewPool = processor.getViewPool(facesContext, root);
ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
Assert.assertNotNull(entry);
Assert.assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult());
endRequest();
}
use of jakarta.faces.component.UIForm in project myfaces by apache.
the class ViewPoolMyFacesRequestTestCase method testStaticPage1_3.
@Test
public void testStaticPage1_3() throws Exception {
Locale locale = null;
startViewRequest("/staticPage.xhtml");
processLifecycleExecute();
locale = facesContext.getViewRoot().getLocale();
executeBeforeRender(facesContext);
executeBuildViewCycle(facesContext);
// Now let's try to remove some component programatically
// that invalidates the view to be reused without a refresh,
// so in the pool it should be marked as REFRESH_REQUIRED
UIForm form = (UIForm) facesContext.getViewRoot().findComponent("mainForm");
form.getChildren().remove(0);
executeViewHandlerRender(facesContext);
executeAfterRender(facesContext);
UIViewRoot root = new UIViewRoot();
root.setLocale(locale);
root.setRenderKitId("HTML_BASIC");
root.setViewId("/staticPage.xhtml");
ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
ViewPool viewPool = processor.getViewPool(facesContext, root);
ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
Assert.assertNotNull(entry);
Assert.assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult());
endRequest();
}
Aggregations