Rahul P
Rahul P

Reputation: 1113

How to display data in struts form if object has another object

I'm working on struts 1.3 framework application. I have one object which I'm setting in request attribute.

request.setAttribute("school",school);

And I'm trying to display that object through <bean:define> tag.

E.g. School is Value Object

School school;

in school VO object I have another two object

Student student;
Teacher teacher;

And I'm trying to display value of student as well as teacher object

<bean:define id="summary" name="school" />
<bean:define id="StudentSummary" name="summary" property="student"/>
<bean:define id="TeacherSummary" name="summary" property="teacher"/>

And writing this element through tag

<bean:write name="StudentSummary" property="name" />
<bean:write name="StudentSummary" property="class" />
<bean:write name="TeacherSummary" property="name" />

But it is giving
javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.MESSAGE

what would be wrong in the code.

Upvotes: 1

Views: 1913

Answers (1)

Susie
Susie

Reputation: 5148

I have never done it using bean tag but you can do it using Expression language(EL). EL, I believe is a more standard way to do things.

Take a look at this previous post. I think it helps Link

I think in your case you can do something along the line of

<c:out value="${school.student.name}"/>

The above statement will print the value of "name", if you have a "name" property in your student object.

Upvotes: 2

Related Questions