Hi all. I'm new with
Struts. I've been reading "Struts in action" book. I'm modifying the first example so that I can enter my name, but also my last name. Something pretty easy and really pisses me off, cause I cant get it working.
Theoretically:
"NameCollector.jsp"
...
<body>
<h4>Enter your name so that we can customize a greeting just for you!</h4>
<s:form action="HelloWorld">
<s:textfield name="namee" label="Your name"/>
<s:textfield name="apellido" label="Your lastname"/>
<s:submit/>
</s:form>
</body>
...
I've added "apellido" (Lastname in spanish xD) and +e to name (Just to check if it kept working).
"HelloWorld.java"
package manning.chapterTwo;
import com.opensymphony.xwork2.ActionSupport;
public class HelloWorld extends ActionSupport {
private static final
String GREETING = "Hello ";
public String execute() {
setCustomGreeting( GREETING + this.getNamee() + " " + getApellido());
return "SUCCESS";
}
private String apellido;
public String getApellido() {
return apelllido;
}
public void setApellido(String apellido) {
this.apellido = apellido;
}
private String namee;
public String getNamee() {
return namee;
}
public void setNamee(String namee) {
this.namee = namee;
}
private String customGreeting;
public String getCustomGreeting()
{
return customGreeting;
}
public void setCustomGreeting( String customGreeting ){
this.customGreeting = customGreeting;
}
}
"struts.xml"
...
<action name="HelloWorld" class="manning.chapterTwo.HelloWorld">
<result name="SUCCESS">/chapterTwo/HelloWorld.jsp</result>
</action>
...
"Helloworld.jsp"
...
<body>
<h3>Custom Greeting Page modificado</h3>
<h4><s:property value="customGreeting"/></h4>
</body>
...
So, I call from a Menu "NameCollector.jsp" (strust.xml does, really).
I load my name and last name.
I get "null" in my output string. Actually, I get "Hello null".
And in my console:
Dec 23, 2011 8:42:06 PM com.opensymphony.xwork2.interceptor.ParametersInterceptor setParameters
SEVERE: ParametersInterceptor - [setParameters]: Unexpected Exception caught setting 'apellido' on 'class manning.chapterTwo.HelloWorld: Error setting expression 'apellido' with value '[Ljava.lang.String;@12164ea'
Dec 23, 2011 8:42:06 PM com.opensymphony.xwork2.interceptor.ParametersInterceptor setParameters
SEVERE: ParametersInterceptor - [setParameters]: Unexpected Exception caught setting 'namee' on 'class manning.chapterTwo.HelloWorld: Error setting expression 'namee' with value '[Ljava.lang.String;@11b456f'
Does anyone know why I get this?. It used to work fine just with name property. I added one "e" to check if it still worked (Changed it everywhere I thought it was necesary) but it stopped working and return a null.
Something i should know?
Thanks in advance! and Marry Christmas!
Mathew.