wood burning stoves 2.0*
The moose likes JSP and the fly likes How to setProperty of nested properties? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to setProperty of nested properties?" Watch "How to setProperty of nested properties?" New topic
Author

How to setProperty of nested properties?

Alex Pi
Greenhorn

Joined: Jan 08, 2013
Posts: 17

I've got 2 JavaBean-classes:

Then i retrieve request parameters in JSP:


How can i set properties for person.address (nested property)? (person.firstName & person.secondName are correct).
Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

As you are using the JSTL and EL why are you bothering with useBean and setProperty at all?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Alex Pi
Greenhorn

Joined: Jan 08, 2013
Posts: 17

Bear Bibeault wrote:As you are using the JSTL and EL why are you bothering with useBean and setProperty at all?

You have catched me. :) I learn JSP, and i still didn't know JSTL.
I know how to use scriptlets but i do first steps (only couple days) with EL.

Perhaps it will be better to ask how could i set nested properties without using scriptlets.
Sai Prasad Sabeson
Greenhorn

Joined: Oct 10, 2011
Posts: 4

Using EL you can set the value of the property inside person


This will set all the params there in the request scope to the bean.Your Address property will be null untill now.

Now,

this can set the values to the bean 'person'.Before you set the value adress ,make sure that you have address bean set up

Hope this helps
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to setProperty of nested properties?