use of jakarta.faces.component.html.HtmlForm in project myfaces by apache.
the class HtmlFormRendererTest method setUp.
public void setUp() throws Exception {
super.setUp();
// application.setViewHandler(new MockTestViewHandler());
form = new HtmlForm();
writer = new MockResponseWriter(new StringWriter(), null, null);
facesContext.setResponseWriter(writer);
facesContext.getViewRoot().setRenderKitId(MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
facesContext.getRenderKit().addRenderer(form.getFamily(), form.getRendererType(), new HtmlFormRenderer());
facesContext.getAttributes().put("org.apache.myfaces.RENDERED_FACES_JS", Boolean.TRUE);
}
use of jakarta.faces.component.html.HtmlForm in project myfaces by apache.
the class HtmlCommandLinkClientBehaviorRendererTest method createComponentToTest.
@Override
protected UIComponent createComponentToTest() {
UIComponent component = new HtmlCommandLink();
UIComponent form = new HtmlForm();
form.getChildren().add(component);
facesContext.getViewRoot().getChildren().add(form);
return component;
}
use of jakarta.faces.component.html.HtmlForm in project myfaces by apache.
the class PartialStateManagementStrategyTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
FactoryFinder.setFactory(FactoryFinder.VISIT_CONTEXT_FACTORY, VisitContextFactoryImpl.class.getName());
RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory("jakarta.faces.render.RenderKitFactory");
renderKit = new MockRenderKit() {
ResponseStateManager stateManager = new ResponseStateManager() {
public Object getState(FacesContext context, String viewId) {
return stateToRestore;
}
};
@Override
public ResponseStateManager getResponseStateManager() {
return stateManager;
}
};
renderKitFactory.addRenderKit("HTML_BASIC2", renderKit);
// FactoryFinder.setFactory(FactoryFinder.VISIT_CONTEXT_FACTORY,
// VisitContextFactoryImpl.class.getName());
renderKit.addRenderer(new HtmlCommandButton().getFamily(), new HtmlCommandButton().getRendererType(), new HtmlButtonRenderer());
renderKit.addRenderer(new HtmlForm().getFamily(), new HtmlForm().getRendererType(), new HtmlFormRenderer());
renderKit.addRenderer(new HtmlOutputText().getFamily(), new HtmlOutputText().getRendererType(), new HtmlTextRenderer());
renderKit.addRenderer(new HtmlInputText().getFamily(), new HtmlInputText().getRendererType(), new HtmlTextRenderer());
}
use of jakarta.faces.component.html.HtmlForm in project myfaces by apache.
the class HtmlInputFileRendererBase method encodeEnd.
@Override
public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
renderInput(facesContext, component);
if (!facesContext.isProjectStage(ProjectStage.Production) && facesContext.isPostback() && (facesContext.getPartialViewContext().isPartialRequest() || facesContext.getPartialViewContext().isAjaxRequest())) {
UIForm form = ComponentUtils.findClosest(UIForm.class, component);
if (form != null && form instanceof HtmlForm) {
String content = ((HtmlForm) form).getEnctype();
if (content == null || !content.contains("multipart/form-data")) {
FacesMessage message = new FacesMessage("file upload requires a form with" + " enctype equal to multipart/form-data");
facesContext.addMessage(component.getClientId(), message);
}
}
}
}
use of jakarta.faces.component.html.HtmlForm in project myfaces by apache.
the class HtmlMessageRendererTest method setUp.
public void setUp() throws Exception {
super.setUp();
writer = new MockResponseWriter(new StringWriter(), null, null);
message = new HtmlMessage();
form = new HtmlForm();
inputText = new HtmlInputText();
facesContext.setResponseWriter(writer);
facesContext.getViewRoot().setRenderKitId(MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
facesContext.getRenderKit().addRenderer(message.getFamily(), message.getRendererType(), new HtmlMessageRenderer());
facesContext.getRenderKit().addRenderer(inputText.getFamily(), inputText.getRendererType(), new HtmlTextRenderer());
facesContext.getRenderKit().addRenderer(form.getFamily(), form.getRendererType(), new HtmlFormRenderer());
// inputText.setParent(form);
inputText.setId("myInputId");
// message.setParent(form);
form.getChildren().add(inputText);
form.getChildren().add(message);
facesContext.getAttributes().put("org.apache.myfaces.RENDERED_FACES_JS", Boolean.TRUE);
}
Aggregations