FileDocCategorySizeDatePackage
UIBeanTest.javaAPI DocExample3275Mon Jul 23 13:26:10 BST 2007org.apache.struts2.components

UIBeanTest

public class UIBeanTest extends org.apache.struts2.StrutsTestCase
version
$Date: 2007-01-20 03:44:14 -0500 (Sat, 20 Jan 2007) $ $Id: UIBeanTest.java 498091 2007-01-20 08:44:14Z mrdon $

Fields Summary
Constructors Summary
Methods Summary
public voidtestPopulateComponentHtmlId1()

        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
        MockHttpServletRequest req = new MockHttpServletRequest();
        MockHttpServletResponse res = new MockHttpServletResponse();

        Form form = new Form(stack, req, res);
        form.getParameters().put("id", "formId");

        TextField txtFld = new TextField(stack, req, res);
        txtFld.setId("txtFldId");

        txtFld.populateComponentHtmlId(form);

        assertEquals("txtFldId", txtFld.getParameters().get("id"));
    
public voidtestPopulateComponentHtmlId2()

        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
        MockHttpServletRequest req = new MockHttpServletRequest();
        MockHttpServletResponse res = new MockHttpServletResponse();

        Form form = new Form(stack, req, res);
        form.getParameters().put("id", "formId");

        TextField txtFld = new TextField(stack, req, res);
        txtFld.setName("txtFldName");

        txtFld.populateComponentHtmlId(form);

        assertEquals("formId_txtFldName", txtFld.getParameters().get("id"));
    
public voidtestPopulateComponentHtmlIdWithOgnl()

        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
        MockHttpServletRequest req = new MockHttpServletRequest();
        MockHttpServletResponse res = new MockHttpServletResponse();

        Form form = new Form(stack, req, res);
        form.getParameters().put("id", "formId");

        TextField txtFld = new TextField(stack, req, res);
        txtFld.setName("txtFldName%{'1'}");

        txtFld.populateComponentHtmlId(form);

        assertEquals("formId_txtFldName1", txtFld.getParameters().get("id"));