Stephen,
This should work just fine (Ognl will convert from String[] to String if it
needs to) – I can’t imagine why this isn’t working. Are you
sure you have xwork.xml correctly configured? The key is to make sure that you
are including webwork-default.xml and that your packages extend “webwork-default”.
Patrick
-----Original Message-----
From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Stephen Smith
Sent: Friday, January 30, 2004
2:05 PM
To:
[EMAIL PROTECTED]
Subject: [OS-webwork] Beginner
WebWork Action problem with String vs [Ljava.lang.String
I'm just starting with webwork-2.0-beta2 and and
xwork-1.0-beta2 (from the WebWork CVS tree) and trying to work through some
examples.
I created a simple Action which is based on Actions taken from various
published examples:
public class HelloWorld implements Action {
private String name;
private String greeting;
public void setName(String name) {
this.name=name;
}
public String getName() {
return name;
}
public String getGreeting() {
return greeting;
}
public String execute() {
greeting = "Hello
"+name;
return SUCCESS;
}
}
Then I call the action with a servlet parameter (?name=Me). The 'setName'
setter never gets called, and looking through the servlet parameters it's
because the parameter is actually of type '[Ljava.lang.String' (an array of
Strings) not a 'String'.
Reading through the messages in this list, I found a reference to this
indicating that this is intentional as any named parameter may have multiple
instances. I'm having trouble unstanding why the examples seem to expect String
while the implementation provides an array of String. Are the examples out of
date? And if so, how should I change my code?
Stephen
|