Package com.opensymphony.xwork2.util

Examples of com.opensymphony.xwork2.util.ValueStack


        property.setValue("top");
        assertPropertyOutput("foo-value/bar-value", property);
    }

    public void testTypeConverterShouldBeUsed() {
        final ValueStack stack = ActionContext.getContext().getValueStack();
        converter.registerConverter("org.apache.struts2.components.PropertyTest$FooBar", new FooBarConverter());
        stack.push(new FooBar("foo-value", "bar-value"));
        final Property property = new Property(stack);
        property.setDefault("default");
        property.setValue("top");
        assertPropertyOutput("*foo-value + bar-value*", property);
    }
View Full Code Here


*/
public class StrutsResultSupportTest extends StrutsInternalTestCase {


    public void testParse() throws Exception {
        ValueStack stack = ActionContext.getContext().getValueStack();
        stack.push(new ActionSupport() {
            public String getMyLocation() {
                return "ThisIsMyLocation";
            }
        });

View Full Code Here

        property.setValue("top");
        assertPropertyOutput("*foo-value + bar-value*", property);
    }

    public void testTypeConverterReturningNullShouldLeadToDisplayOfDefaultValue() {
        final ValueStack stack = ActionContext.getContext().getValueStack();
        converter.registerConverter("org.apache.struts2.components.PropertyTest$FooBar", new FooBarConverter());
        stack.push(new FooBar("foo-value", null));
        final Property property = new Property(stack);
        property.setDefault("default");
        property.setValue("top");
        assertPropertyOutput("default", property);
    }
View Full Code Here

        assertEquals("/pages/myJsp.jsp?location=ThisIsMyLocation", result.getInternalLocation());
        EasyMock.verify(mockActionInvocation);
    }

    public void testParseAndEncode() throws Exception {
        ValueStack stack = ActionContext.getContext().getValueStack();
        stack.push(new ActionSupport() {
            public String getMyLocation() {
                return "/myPage?param=value&param1=value1";
            }
        });
View Full Code Here

        EasyMock.verify(mockActionInvocation);
    }


    public void testNoParseAndEncode() throws Exception {
        ValueStack stack = ActionContext.getContext().getValueStack();
        stack.push(new ActionSupport() {
            public String getMyLocation() {
                return "myLocation.jsp";
            }
        });
View Full Code Here

    protected abstract Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res);

    public boolean render(InternalContextAdapter ctx, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
        // get the bean
        ValueStack stack = (ValueStack) ctx.get("stack");
        HttpServletRequest req = (HttpServletRequest) stack.getContext().get(ServletActionContext.HTTP_REQUEST);
        HttpServletResponse res = (HttpServletResponse) stack.getContext().get(ServletActionContext.HTTP_RESPONSE);
        Component bean = getBean(stack, req, res);
        Container container = (Container) stack.getContext().get(ActionContext.CONTAINER);
        container.inject(bean);
        // get the parameters
        Map params = createPropertyMap(ctx, node);
        bean.copyParams(params);
        //bean.addAllParameters(params);
View Full Code Here

        result.setChart(mockChart);

        result.setHeight("${myHeight}");
        result.setWidth("${myWidth}");

        ValueStack stack = ActionContext.getContext().getValueStack();
        stack.set("myHeight", 250);
        stack.set("myWidth", 150);

        result.execute(actionInvocation);

        EasyMock.verify(responseMock);
        assertEquals(result.getHeight(), stack.findValue("myHeight").toString());
        assertEquals(result.getWidth(), stack.findValue("myWidth").toString());
        assertEquals("250", result.getHeight().toString());
        assertEquals("150", result.getWidth().toString());
        assertTrue(os.isWritten());
    }
View Full Code Here

                validatorCache.put(validatorKey, buildValidatorConfigs(clazz, context, true, null));
            }
        } else {
            validatorCache.put(validatorKey, buildValidatorConfigs(clazz, context, false, null));
        }
        ValueStack stack = ActionContext.getContext().getValueStack();

        // get the set of validator configs
        List<ValidatorConfig> cfgs = validatorCache.get(validatorKey);

        // create clean instances of the validators for the caller's use
View Full Code Here

        String listValue = (String) params.get("listValue");
        // NameValue is the value that is provided by the name property in the action
        Object nameValue = params.get("nameValue");
        int cnt = 0;

        ValueStack stack = this.context.getStack();
        if (listObj != null) {
            Iterator itt = MakeIterator.convert(listObj);
            while (itt.hasNext()) {
                Object item = itt.next();
                stack.push(item);

                //key
                Object itemKey = findValue(listKey != null ? listKey : "top");
                String itemKeyStr = StringUtils.defaultString(itemKey == null ? null : itemKey.toString());

                //value
                Object itemValue = findValue(listValue != null ? listValue : "top");
                String itemValueStr = StringUtils.defaultString(itemValue == null ? null : itemValue.toString());

                // nameValue needs to cast to a string from object
                String itemNameValueStr = (nameValue == null ? null : nameValue.toString());

                //Checked value.  It's set to true if the nameValue (the value associated with the name which is typically set in
                //the action is equal to the current key value.
                Boolean checked = itemKeyStr != null && itemNameValueStr != null && itemNameValueStr.equals(itemKeyStr);

                //Radio button section
                String id = params.get("id") + Integer.toString(cnt++);
                Attributes a = new Attributes();
                a.add("type", "radio")
                        .addDefaultToEmpty("name", params.get("name"))
                        .addIfTrue("checked", checked)
                        .addIfExists("value", itemKeyStr)
                        .addIfTrue("disabled", params.get("disabled"))
                        .addIfExists("tabindex", params.get("tabindex"))
                        .addIfExists("id", id);
                super.start("input", a);
                super.end("input");

                //Label section
                a = new Attributes();
                a.addIfExists("for", id)
                        .addIfExists("class", params.get("cssClass"))
                        .addIfExists("style", params.get("cssStyle"))
                        .addIfExists("title", params.get("title"));
                super.start("label", a);
                if (StringUtils.isNotEmpty(itemValueStr)) {
                    characters(itemValueStr);
                }
                super.end("label");
                stack.pop();
            }
        }
    }
View Full Code Here

        String id = (String) params.get("id");

        int cnt = 1;

        //This will interate through all lists
        ValueStack stack = this.context.getStack();
        if (listObj != null) {
            Iterator itt = MakeIterator.convert(listObj);
            while (itt.hasNext()) {
                Object item = itt.next();
                stack.push(item);

                //key
                Object itemKey = findValue(listKey != null ? listKey : "top");
                String itemKeyStr = StringUtils.defaultString(itemKey == null ? null : itemKey.toString());

                //value
                Object itemValue = findValue(listValue != null ? listValue : "top");
                String itemValueStr = StringUtils.defaultString(itemValue == null ? null : itemValue.toString());

                //Checkbox button section
                Attributes a = new Attributes();
                a.add("type", "checkbox")
                  .add("name", name)
                  .add("value", itemKeyStr)
                  .addIfTrue("checked", isChecked(params, itemKeyStr))
                  .addIfTrue("readonly", params.get("readonly"))
                  .addIfTrue("disabled", disabled)
                  .addIfExists("tabindex", params.get("tabindex"))
                    .addIfExists("id", id + "-" + Integer.toString(cnt));
            start("input", a);
            end("input");

                //Label section
                a = new Attributes();
                a.add("for",id + "-" + Integer.toString(cnt))
                  .addIfExists("class", params.get("cssClass"))
                  .addIfExists("style", params.get("cssStyle"));
                super.start("label", a);
                if (StringUtils.isNotEmpty(itemValueStr))
                    characters(itemValueStr);
                super.end("label");

                //Hidden input section
                a = new Attributes();
                a.add("type", "hidden")
                        .add("id", "__multiselect_" + StringUtils.defaultString(StringEscapeUtils.escapeHtml4(id)))
                        .add("name", "__multiselect_" + StringUtils.defaultString(StringEscapeUtils.escapeHtml4(name)))
                        .add("value", "")
                        .addIfTrue("disabled", disabled);
                start("input", a);
                end("input");

                stack.pop();
                cnt++;
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.opensymphony.xwork2.util.ValueStack

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.