my dog learned polymorphism*
The moose likes JSF and the fly likes Problem With Indexed Property Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Problem With Indexed Property" Watch "Problem With Indexed Property" New topic
Author

Problem With Indexed Property

Kaustabh Singha Roy
Ranch Hand

Joined: Oct 04, 2005
Posts: 43
Hi,

I have a form where the number of input is variable depending on database data. A series of <h:inputText> will appear which can be edited and on submit the altered values will be saved to the database. To hold the data I have a property of type ArrayList in the backing bean.



If I use the indexed property like the following then I am getting the proper effect..



All I need to do is make some arrangement so that the above list of text boxes apper dynamically depending on the number of items present in the bean property "name". I can not keep a fixed number of inputs as this will varry in number. I have tried a lot with the <c:forEach> to get this effect but without success. Can anybody help me out please.

Thanks in advance.

Kaustabh
Dushyant Agarwal
Ranch Hand

Joined: Oct 14, 2007
Posts: 75
Hi,
You could use a standard JSF data Table compnent. It might contain single column. That column may contain an InputText component. The value of the data table should be binded with the arrayList that contains the differnt names to be displayed....
The InputText in the column may be value bounded to another String which might be in the backing bean so that whatever input arrives in the inputText is acquired in it.
Kaustabh Singha Roy
Ranch Hand

Joined: Oct 04, 2005
Posts: 43
Thanks,

I actually tried that too. Like below



The problem is the texts should be displayed with the values in the property "names"(this is happening) and if the values are changed then the altered values should be stored bank in the respective position in the same property "names"(this is not happening).

Regards.
[ January 16, 2008: Message edited by: Kaustabh Singha Roy ]
Dushyant Agarwal
Ranch Hand

Joined: Oct 14, 2007
Posts: 75
Hi,
You could try the following code
Kaustabh Singha Roy
Ranch Hand

Joined: Oct 04, 2005
Posts: 43
Thanks, I have got solution of this problem. All we need to do is to use a value object to enclose the data of one row. This one level of abstraction is required. I am not sure however wheter this is intended behavior or a bug.

Regards.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem With Indexed Property
 
Similar Threads
querystring values and GET method
Struts: How does indexed data get into a Form Bean?
Help Please?
Automatic Population of Indexed Fields
Nested Iterator Tags