use of jakarta.faces.component.html.HtmlOutputText in project myfaces by apache.
the class HtmlGridRendererTest method setUp.
public void setUp() throws Exception {
super.setUp();
panelGrid = new HtmlPanelGrid();
colText = new HtmlOutputText();
writer = new MockResponseWriter(new StringWriter(), null, null);
facesContext.setResponseWriter(writer);
facesContext.getViewRoot().setRenderKitId(MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
facesContext.getRenderKit().addRenderer(panelGrid.getFamily(), panelGrid.getRendererType(), new HtmlGridRenderer());
facesContext.getRenderKit().addRenderer(colText.getFamily(), colText.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 HtmlGridRendererTest method testRenderTable.
public void testRenderTable() throws Exception {
UIColumn col1 = new UIColumn();
HtmlOutputText col1Text = new HtmlOutputText();
col1Text.setValue("col1Text");
UIColumn col2 = new UIColumn();
HtmlOutputText col2Text = new HtmlOutputText();
col2Text.setValue("col2Text");
col1.getChildren().add(col1Text);
col2.getChildren().add(col2Text);
panelGrid.getChildren().add(col1);
panelGrid.getChildren().add(col2);
panelGrid.encodeBegin(facesContext);
panelGrid.encodeChildren(facesContext);
panelGrid.encodeEnd(facesContext);
facesContext.renderResponse();
String output = writer.getWriter().toString();
Assert.assertEquals("<table><tbody>" + "<tr><td>col1Text</td></tr>" + "<tr><td>col2Text</td></tr>" + "</tbody>" + "</table>", output);
}
use of jakarta.faces.component.html.HtmlOutputText in project myfaces by apache.
the class UIDataRowStateTest method testChangeIdsAfterSetRowIndex.
/**
*/
@Test
public void testChangeIdsAfterSetRowIndex() {
List<Item> list = new ArrayList<Item>();
int rowCount = 10;
for (int i = 0; i < rowCount; i++) {
list.add(new Item(i, "name" + i, "lastName" + i));
}
facesContext.getExternalContext().getRequestMap().put("items", list);
UIViewRoot root = facesContext.getViewRoot();
UIData data = new HtmlDataTable();
data.setId("table");
root.getChildren().add(data);
data.setValue(new ListDataModel(list));
data.setVar("item");
data.setRows(rowCount);
UIColumn col = new HtmlColumn();
data.getChildren().add(col);
UIOutput text = new HtmlOutputText();
text.setId("text");
text.setValue(facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), "#{item.name}", String.class));
col.getChildren().add(text);
for (int i = 0; i < rowCount; i++) {
data.setRowIndex(i);
Assert.assertEquals(data.getId() + ":" + i + ":" + text.getId(), text.getClientId());
}
data.setRowIndex(-1);
Assert.assertEquals(data.getId() + ":" + text.getId(), text.getClientId());
}
use of jakarta.faces.component.html.HtmlOutputText in project myfaces by apache.
the class UIDataRowStateTest method setUpRenderKit.
@Override
protected void setUpRenderKit() throws Exception {
super.setUpRenderKit();
renderKit.addRenderer(HtmlDataTable.COMPONENT_FAMILY, new HtmlDataTable().getRendererType(), new Renderer() {
});
renderKit.addRenderer(HtmlOutputText.COMPONENT_FAMILY, new HtmlOutputText().getRendererType(), new Renderer() {
});
renderKit.addRenderer(HtmlInputText.COMPONENT_FAMILY, new HtmlInputText().getRendererType(), new Renderer() {
});
}
use of jakarta.faces.component.html.HtmlOutputText in project myfaces by apache.
the class UIDataRowStateTest method testEditableValueHolderState.
/**
* Check if EditableValueHolder is being saved and restored.
*/
@Test
public void testEditableValueHolderState() {
List<Item> list = new ArrayList<Item>();
int rowCount = 10;
for (int i = 0; i < rowCount; i++) {
list.add(new Item(i, "name" + i, "lastName" + i));
}
facesContext.getExternalContext().getRequestMap().put("items", list);
UIViewRoot root = facesContext.getViewRoot();
UIData data = new HtmlDataTable();
data.setId("table");
root.getChildren().add(data);
data.setValue(new ListDataModel(list));
data.setVar("item");
data.setRows(rowCount);
UIColumn col = new HtmlColumn();
data.getChildren().add(col);
UIOutput text = new HtmlOutputText();
text.setId("text");
text.setValue(facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), "#{item.name}", String.class));
col.getChildren().add(text);
UIInput inputText = new HtmlInputText();
inputText.setId("text");
inputText.setValue(facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), "#{item.lastName}", String.class));
col.getChildren().add(inputText);
for (int i = 0; i < rowCount; i++) {
data.setRowIndex(i);
inputText.setSubmittedValue("someString" + i);
}
data.setRowIndex(-1);
for (int i = 0; i < rowCount; i++) {
data.setRowIndex(i);
Assert.assertEquals("someString" + i, inputText.getSubmittedValue());
}
}
Aggregations