File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Set bean property values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Set bean property values" Watch "Set bean property values" New topic

Set bean property values

Alex Casu

Joined: Aug 04, 2011
Posts: 2
Hi this is my first thred i hope somebody can help me,
i use struts 1.3,
in a jsp i iterate a bean collection, that may have N objects, and dynamically create a table,
each <tr> have the same inputs with same name but with different value that can be changed from user.
i can't set form-bean properties with the bean properties because i have a collection of bean
how can display the values of different bean properties if i have one bean-form associated ?

sorry for my bad english i hope somebody have understood

any help is appreciated,

Rajagopal Mani
Ranch Hand

Joined: Mar 24, 2011
Posts: 84


Welcome to JavaRanch.

Hope below code snippets may help you.

In Action,

Alex Casu

Joined: Aug 04, 2011
Posts: 2
Rajagopal Mani wrote:Hi,

Welcome to JavaRanch.

Hope below code snippets may help you.


Hi Rajagopal thanks for you reply but i've solved, i has something like this

every TR is the rappresentation of different bean ex. tr_0 = bean at index 0, tr_1 = bean at index 1 ... and so on..
the user can change one o more inputs value of one o more tr, after save in the combo fields must be selected the new value.
something like html <option value="value" selected="selected" >item 1</option>

//before user's changes
and so on...

//after user's changes
my tryed in this way:

in the end of jsp i call js function like document.onLoad=myFunction();

//with jstl
get beanCollection and iterate it
//with js
get tbody container and iterate it
match tr and bean having the same index
get all tr select fields and iterate it
if == beanpropertyname or form-bean property(it's the same) set values //i think this step is not elegant because i must know what property i need to get//
comboField.value = <cut value="${}"/>

it works fine

I agree. Here's the link:
subject: Set bean property values
It's not a secret anymore!