aspose file tools*
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
Author

Set bean property values

Alex Casu
Greenhorn

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,
tnx

Alex
Rajagopal Mani
Ranch Hand

Joined: Mar 24, 2011
Posts: 84

Hi,

Welcome to JavaRanch.

Hope below code snippets may help you.

In Action,


In JSP
Alex Casu
Greenhorn

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

Welcome to JavaRanch.

Hope below code snippets may help you.

In JSP


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>
ex.

//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();

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 comboField.id == 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="${bean.property}"/>
}

it works fine

Alex
 
wood burning stoves
 
subject: Set bean property values