struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maxx <maxx...@gmail.com>
Subject Unable to make Type Conversion work in Struts2
Date Fri, 15 Feb 2008 18:52:37 GMT
Hello,

Refering to http://struts.apache.org/2.x/docs/type-conversion.html ,
I'm currently trying to make Type Conversion working on a really
simple example. And unfortunately, nothing's working. Below are the
sources.

Could someone please tell what I'm doing wrong (I suspect something
with the OGNL expressions but could not found what...)

Greets,
Maxx

PS: the <s:iterator> doesn't display anything, but if you move the
testList under a JavaBean (e.g. TestBean) and you change testList to
testBean.testList as OGNL value everywhere it's used (esp. for the
iterator), it displays the values in the list... BUT the textfields
still do not work, as while submitting the form, there are some
Exceptions in the log which say:
ParametersInterceptor - [setParameters]: Unexpected Exception caught
setting 'testBean.testList(0)' on 'class
com.mycompany.somepacakge.action.TestAction: Error setting expression
'testBean.testList(0)' with value '[Ljava.lang.String;@102011a'

---

// TestAction.java
public class TestAction {

    public String execute() {

        List<String> testList = new ArrayList<String>(2);
        testList.add("LIST 1st VALUE");
        testList.add("LIST 2nd VALUE");
        setTestList(testList);

        return INPUT;

    }

    public List<String> getTestList() {
        return (List<String>) session.get("list");
    }

    public void setTestList(List<String> list) {
        session.put(list, "list");
    }


}


// TestAction-conversion.properties
Element_testList=java.lang.String


// test.jsp
<%@page language="java" contentType="text/html; charset=ISO-8859-1"%>
<%@taglib prefix="s" uri="/struts-tags"%>

<s:form id="testForm" action="Test" method="post">
<pre>
	Direct access: = does not work
	testList(0) = <s:property value="testList(0)" />
	testList(1) = <s:property value="testList(1)" />

	Regular iterator: = does not work
<s:iterator value="testList" status="stat">
	testList(<s:property value="#stat.index"/>) = <s:property value="top"
/> // <s:textfield name="testList(%{#stat.index})" />
</s:iterator>
</pre>
	<s:submit id="submitBtn" value="Submit Test" action="Test" />
</s:form>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message