Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Set bean property values

 
Alex Casu
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 84
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch.

Hope below code snippets may help you.

In Action,


In JSP
 
Alex Casu
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic