Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problems with bean:write

 
Mike Phillip
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I have a form (MyForm) that has a bean (Car). The Action (MyAction) sets the value of the car property.

Then I want to show in the .jsp file the properties inside the Car bean (model, year...)

after the action sets the property the jsp has the following:

<logic resent name="myForm" property="car">
Car model <bean:write name="car" property="model"/><br>
</logic resent>

but it doesn't works, says that the bean car is not present.

When I do

<logic resent name="myForm" property="car">
Car model <bean:write name="myForm" property="car"/><br>
</logic resent>

it prints the car.toString

I need to get the car and then print its properties.

any help?

thanks
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike,
It's a two step process. First get a reference to the car:
<bean:define id="myCar" name="myForm" property="car" />

Then print out the model:
<bean:write name="car" property="model" />
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another option is to use "dot" notation. Example:

This will cause Struts to perform the following method calls:

[ May 03, 2008: Message edited by: Merrill Higginson ]
 
Mike Phillip
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks guys, I'll try that.


best regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic