useBean in JSP for bean within a bean

K

kumar

I have a 'CustomerForm' bean that has an 'Address' bean that has a
property 'city'.

My Code:
<jsp:useBean id="customerForm" scope="session"
class="com.abc.forms.CustomerForm" />
<jsp:getProperty name="customerForm" property="billingAddress.city" />

CustomerForm does have getter/ setter for Address object and so does
Address for city field. I do know of tag in struts like

<html:text name="customerForm" property="billingAddress.city"
maxlength='40' size="40"/>

that woudl serve the purpose. but it has limitations. The limitation
being, I cannot access the text box element within javascript with its
name translating to 'billingAddress.city'.

Can any one provide me with a solution for the above scenario?

Appreciate our help.
Thanx
 
W

Wendy S

kumar said:
<html:text name="customerForm" property="billingAddress.city"
maxlength='40' size="40"/>

that woudl serve the purpose. but it has limitations. The limitation
being, I cannot access the text box element within javascript with its
name translating to 'billingAddress.city'.

By the time the JavaScript runs (on the client side), that Struts tag will
have been transformed into a plain old HTML <input type="text" ...> tag.
JavaScript is never going to see 'billingAddress.city'.

Another option would be JSTL:
<c:eek:ut value="${customer.billingAddress.city}"/>
(or just the expression, if you're on Servlet 2.4).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top