Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Set bean property values

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 84
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 = <c:out value="${bean.property}"/>
}

it works fine

Alex
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic