I am not able to make <stripes:text> correctly set a deep-level property. Not
sure if I am missing something.
The "state" name is not getting set, even though setting Id attr is optional.
sayhello.jsp displays:
--------------------------------------------------------
Hello Joe your age is 19 and state is {actionBean.person.state.name}
--------------------------------------------------------
The code is as straightforward as I can make
and it beats me. Thanks for any help.
helloworld.jsp
------------
<%@ taglib prefix="stripes"
uri="http://stripes.sourceforge.net/stripes.tld" %>
<html>
<head>
<title>Stripes Hello World</title>
</head>
<body>
<stripes:errors/>
<stripes:form
beanclass="srini.learn.action.HelloWorldAction">
Say hello to: <br>
First name: <stripes:text name="person.firstName"/>
<br>
Age:<stripes:text name="person.age"/><br>
State:<stripes:text name="person.state.name"/><br>
<stripes:submit name="hello" value="Say Hello"/>
</stripes:form>
</body>
</html>
----------------------------
sayhello.jsp
-----------
<%@ taglib prefix="stripes"
uri="http://stripes.sourceforge.net/stripes.tld" %>
<html>
<body>
<stripes:errors/>
<h2>Hello ${actionBean.person.firstName} your age is
${actionBean.person.age} and state is
{actionBean.person.state.name}</h2>
<p/>
<stripes:link beanclass="srini.learn.action.HelloWorldAction">
Say Hello Again
</stripes:link>
</body>
</html>
------------------------------------------
HelloWorldAction.java
------------------
package srini.learn.action;
import srini.learn.model.Person;
import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.validation.Validate;
import net.sourceforge.stripes.validation.ValidateNestedProperties;
public class HelloWorldAction implements ActionBean {
@ValidateNestedProperties({
@Validate(field = "firstName", required = true,
on = {"hello"}),
@Validate(field = "age", required = true, minvalue = 13,
on = {"hello"})
})
private Person person;
private ActionBeanContext context;
@DefaultHandler
public Resolution index() {
return new ForwardResolution("/helloworld.jsp");
}
public Resolution hello() {
return new ForwardResolution("/sayhello.jsp");
}
public Person getPerson() {
return person;
}
public void setPerson(Person person) {
this.person = person;
}
public void setContext(ActionBeanContext c) {this.context = c; }
public ActionBeanContext getContext() {return context; }
}
-------------------------
Person.java
---------
package srini.learn.model;
public class Person {
private String firstName;
private Integer age;
private State state;
public State getState() {
return state;
}
public void setState(State state) {
this.state = state;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
-------------------
State.java
---------
package srini.learn.model;
public class State {
private Integer id;
private String name;
public State() {
}
public State (Integer id, String name){
this.id = id;
this.name = name;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
-----------------------------
------------------------------------------------------------------------------
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development