• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts 2: Action objects not passed to JSP

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am building a web application using Struts 2 when I come across a seem-to-be weird problem.

Well defined object attributes in action class sometimes cannot not be passed to JSP. But sometimes it works just fine and everything shows in JSP corretly.

It happens very radomly and I really cannot tell the pattern.

I have made sure that before the action return 'SUCCESS' the objects are still there, whereas on the jsp side, they turn into nulls.

The following is section of my struts.xml:

<action name="launch" class="org.delta.qa.web.action.MemberInquiryAction" >
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="inputValidator"/>
<result name="success">jsp/MemberInquiry.jsp</result>
<result name="error">jsp/error.jsp</result>
<result name="new_member" type="chain">preprocess</result>
</action>

Do I need to define the object type in struts.xml or somewhere else?

Any help would greatly appreciated!!

Jonathan
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm afraid we don't have enough information to be of much help. Could you please post relevant portions of your MemberInquiryAction class and JSP?
 
Jonathan Su
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my scenario in more detail:

Class AbcActionBean extends ActionSupport {
protected MemberEntity member; //MemberEntity is defined in Entity package.
with public getter and setter.
}

Class MemberInquiryAction extends AbcBean {
execute() {
.......
member is populated from DB.
.......
// at this point member is still populated
return SUCCESS;
}
}

In JSP side, I am trying to display member info like this
<input type="text" name="member.firstName" value"${member.firstName}"/>
or directly, <td>${member.age}</td>

For debug purpose I display ${member} on the screen just to see if the object is there.

Very randomly when the jsp is display the member object become null and obviously no attribute of it would show. If I repeat the same action it would show again.

Please help.

Jonathan
 
Jonathan Su
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One thing I notice is that only the types I defined in the application have this problem. String, ArrayList (although has custom-defined components), int, float etc, can be passed without any issue.
 
reply
    Bookmark Topic Watch Topic
  • New Topic