use of jakarta.faces.component.html.HtmlOutputText in project myfaces by apache.
the class HtmlTableRendererTest method testNoRowCountRender.
/**
* Check table renderer behavior when DataModel returns -1 from getRowCount(). It should
* render the same as if that value is provided. Note t:dataTable newspaper mode requires
* row count to calculate newspaperRows and newspaperColumns.
*/
public void testNoRowCountRender() {
List<Person> list = new ArrayList<Person>();
list.add(new Person("John", "Smith"));
list.add(new Person("Pepito", "Perez"));
list.add(new Person("Kurt", "Kobain"));
dataTable.setId("data");
dataTable.setRowClasses("class1, class2");
dataTable.setVar("person");
UIColumn column1 = new UIColumn();
HtmlOutputText text = new HtmlOutputText();
text.setValueExpression("value", facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), "#{person.firstName}", String.class));
column1.getChildren().add(text);
dataTable.getChildren().add(column1);
UIColumn column2 = new UIColumn();
HtmlOutputText text2 = new HtmlOutputText();
text2.setValueExpression("value", facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), "#{person.lastName}", String.class));
column2.getChildren().add(text2);
dataTable.getChildren().add(column2);
dataTable.setValue(new UnknownRowCountDemoDataModel<Person>(list));
String output1 = null;
try {
dataTable.encodeAll(facesContext);
output1 = ((StringWriter) writer.getWriter()).getBuffer().toString();
} catch (Exception e) {
Assert.fail(e.getMessage());
}
dataTable.setValue(new ListDataModel<Person>(list));
((StringWriter) writer.getWriter()).getBuffer().setLength(0);
String output2 = null;
try {
dataTable.encodeAll(facesContext);
output2 = ((StringWriter) writer.getWriter()).getBuffer().toString();
} catch (Exception e) {
Assert.fail(e.getMessage());
}
Assert.assertTrue(output2.contains("John"));
Assert.assertTrue(output2.contains("Smith"));
Assert.assertTrue(output2.contains("class1"));
Assert.assertTrue(output2.contains("class2"));
Assert.assertTrue(output1.contains("John"));
Assert.assertTrue(output1.contains("Smith"));
Assert.assertTrue(output1.contains("class1"));
Assert.assertTrue(output1.contains("class2"));
Assert.assertEquals(output2, output1);
}
use of jakarta.faces.component.html.HtmlOutputText in project myfaces by apache.
the class HtmlTableRendererTest method setUp.
public void setUp() throws Exception {
super.setUp();
dataTable = new HtmlDataTable();
writer = new MockResponseWriter(new StringWriter(), null, null);
facesContext.setResponseWriter(writer);
facesContext.getViewRoot().setRenderKitId(MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
facesContext.getRenderKit().addRenderer(dataTable.getFamily(), dataTable.getRendererType(), new HtmlTableRenderer());
HtmlOutputText text = new HtmlOutputText();
facesContext.getRenderKit().addRenderer(text.getFamily(), text.getRendererType(), new HtmlTextRenderer());
facesContext.getAttributes().put("org.apache.myfaces.RENDERED_FACES_JS", Boolean.TRUE);
}
use of jakarta.faces.component.html.HtmlOutputText in project myfaces by apache.
the class HtmlTextRendererTest method setUp.
public void setUp() throws Exception {
super.setUp();
servletContext.addInitParameter(MyfacesConfig.RENDER_CLIENTBEHAVIOR_SCRIPTS_AS_STRING, "true");
outputText = new HtmlOutputText();
inputText = new HtmlInputText();
writer = new MockResponseWriter(new StringWriter(), null, null);
facesContext.setResponseWriter(writer);
// TODO remove these two lines once myfaces-test goes alpha, see MYFACES-1155
facesContext.getViewRoot().setRenderKitId(MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
facesContext.getRenderKit().addRenderer(outputText.getFamily(), outputText.getRendererType(), new HtmlTextRenderer());
facesContext.getRenderKit().addRenderer(inputText.getFamily(), inputText.getRendererType(), new HtmlTextRenderer());
facesContext.getAttributes().put("org.apache.myfaces.RENDERED_FACES_JS", Boolean.TRUE);
}
use of jakarta.faces.component.html.HtmlOutputText in project myfaces by apache.
the class HtmlEscapeRendererTest method setUp.
public void setUp() throws Exception {
super.setUp();
outputText = new HtmlOutputText();
outputLabel = new HtmlOutputLabel();
selectOneRadio = new HtmlSelectOneRadio();
selectOneListbox = new HtmlSelectOneListbox();
selectOneMenu = new HtmlSelectOneMenu();
selectManyCheckbox = new HtmlSelectManyCheckbox();
selectManyListbox = new HtmlSelectManyListbox();
selectManyMenu = new HtmlSelectManyMenu();
// TODO remove these two lines once myfaces-test goes alpha, see MYFACES-1155
facesContext.getViewRoot().setRenderKitId(MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
facesContext.getRenderKit().addRenderer(outputText.getFamily(), outputText.getRendererType(), new HtmlTextRenderer());
facesContext.getRenderKit().addRenderer(outputLabel.getFamily(), outputLabel.getRendererType(), new HtmlLabelRenderer());
facesContext.getRenderKit().addRenderer(selectOneRadio.getFamily(), selectOneRadio.getRendererType(), new HtmlRadioRenderer());
facesContext.getRenderKit().addRenderer(selectOneListbox.getFamily(), selectOneListbox.getRendererType(), new HtmlListboxRenderer());
facesContext.getRenderKit().addRenderer(selectOneMenu.getFamily(), selectOneMenu.getRendererType(), new HtmlMenuRenderer());
facesContext.getRenderKit().addRenderer(selectManyCheckbox.getFamily(), selectManyCheckbox.getRendererType(), new HtmlCheckboxRenderer());
facesContext.getRenderKit().addRenderer(selectManyListbox.getFamily(), selectManyListbox.getRendererType(), new HtmlListboxRenderer());
facesContext.getRenderKit().addRenderer(selectManyMenu.getFamily(), selectManyMenu.getRendererType(), new HtmlMenuRenderer());
facesContext.getAttributes().put("org.apache.myfaces.RENDERED_FACES_JS", Boolean.TRUE);
}
use of jakarta.faces.component.html.HtmlOutputText in project myfaces by apache.
the class HtmlGroupRendererTest method setUp.
public void setUp() throws Exception {
super.setUp();
servletContext.addInitParameter(MyfacesConfig.RENDER_CLIENTBEHAVIOR_SCRIPTS_AS_STRING, "true");
panelGroup = new HtmlPanelGroup();
HtmlOutputText panelChildOutputText = new HtmlOutputText();
panelChildOutputText.setValue(PANEL_CHILD_TEXT);
panelGroup.getChildren().add(panelChildOutputText);
writer = new MockResponseWriter(new StringWriter(), null, null);
facesContext.setResponseWriter(writer);
facesContext.getViewRoot().setRenderKitId(MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
facesContext.getRenderKit().addRenderer(panelGroup.getFamily(), panelGroup.getRendererType(), new HtmlGroupRenderer());
facesContext.getRenderKit().addRenderer(panelChildOutputText.getFamily(), panelChildOutputText.getRendererType(), new HtmlTextRenderer());
facesContext.getRenderKit().addClientBehaviorRenderer(AjaxBehavior.BEHAVIOR_ID, new HtmlAjaxBehaviorRenderer());
facesContext.getAttributes().put("org.apache.myfaces.RENDERED_FACES_JS", Boolean.TRUE);
}
Aggregations