use of jakarta.faces.component.html.HtmlInputText 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.HtmlInputText in project myfaces by apache.
the class OwnRenderkitTest method setUp.
public void setUp() throws Exception {
super.setUp();
addRenderKit();
inputText = new HtmlInputText();
writer = new MockResponseWriter(new StringWriter(), null, null);
facesContext.setResponseWriter(writer);
MockFacesContext12.getCurrentInstance();
facesContext.getViewRoot().setRenderKitId("OWN_BASIC");
facesContext.getRenderKit().addRenderer(inputText.getFamily(), inputText.getRendererType(), new HtmlTextRenderer());
}
use of jakarta.faces.component.html.HtmlInputText in project myfaces by apache.
the class MessageUtilsTest method testGetLabelReturnsClientIdWhenLabelIsNotSpecified.
public void testGetLabelReturnsClientIdWhenLabelIsNotSpecified() {
HtmlInputText inputText = new HtmlInputText();
inputText.setId("testId");
Object label = MessageUtils.getLabel(facesContext, inputText);
Assert.assertEquals("testId", label);
}
use of jakarta.faces.component.html.HtmlInputText in project myfaces by apache.
the class MessageUtilsTest method testGetLabelFromValueExpression.
public void testGetLabelFromValueExpression() {
facesContext.getExternalContext().getRequestMap().put("lbl", "testLabel");
HtmlInputText inputText = new HtmlInputText();
ValueExpression expression = new MockValueExpression("#{requestScope.lbl}", String.class);
inputText.setValueExpression("label", expression);
Object label = MessageUtils.getLabel(facesContext, inputText);
Assert.assertEquals("testLabel", label);
}
use of jakarta.faces.component.html.HtmlInputText in project myfaces by apache.
the class UIDataRowStateTest method testChangeIdsAfterSetRowIndex2.
@Test
public void testChangeIdsAfterSetRowIndex2() {
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);
Assert.assertEquals(data.getId() + ":" + i + ":" + text.getId(), text.getClientId());
Assert.assertEquals(data.getId() + ":" + i + ":" + inputText.getId(), inputText.getClientId());
}
data.setRowIndex(-1);
Assert.assertEquals(data.getId() + ":" + text.getId(), text.getClientId());
Assert.assertEquals(data.getId() + ":" + inputText.getId(), inputText.getClientId());
}
Aggregations