• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSF and trinidad- Help with multiple iterations in a table

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, im very new to the JSF framework and apache trinidad. I need help with what many of you will probably think is very trivial, but i really can't figure this out at all!!

I am working on a page which collects a user's input via a textfield. the top level textfield is called "procedure". there is an add button which allows the user to add more than one procedure per page, and also a remove button as well. The Procedure object has one string called label, and a string array of tags.

The user is supposed to be able to add multiple "tag" textfields for each procedure. This is the part that i am stuck on. Basically, every Procedure object can contain an array of strings called "tag". Im just not too sure how to code it in the view. The following code does add a new string in the array, but does not allow for the actual input of tags from the page.



Can someone help me troubleshoot my logic?

 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nest another table or list component inside the column for the tags.
 
Dave Joseph
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bauke Scholtz wrote:Nest another table or list component inside the column for the tags.



I am still not too sure on what binds an array's current index. when i click the add button on the inside array, i create another " string". what should be placed inside the [index]?



 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't need to specify the index. The UIData does it itself.
 
Dave Joseph
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bauke Scholtz wrote:You don't need to specify the index. The UIData does it itself.




i really appreciate your help so far and i'm almost there!



the inputText field with "#{tagRow}" now returns the value of what's inside the array, but i still can't set it (set tag) is never applied. When i click add tag, the test value "something added here" is added into the array, and that's what returns in the inputText area.



Here is my bean code.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The setter of a list or datamodel will indeed never be called. EL will only get the list by the getter and then add the item to the obtained list.
 
Dave Joseph
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bauke Scholtz wrote:The setter of a list or datamodel will indeed never be called. EL will only get the list by the getter and then add the item to the obtained list.



That's rather confusing. I've been trying to find some good documentation online for this but after searching all morning i still can't find an example like the one i'm working with. I've only been able to find ones where single variables are set (phone number, first name, last name), but never a collection/arraylist.

how can the item added if it can never be read (or set) in from the page?
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It works just the same way as your parent table, the tr:table. The setter of its value, #{DocumentBean.proList}", is also never been called.

JSF EL doesn't do like the following:
List list = new List();
list.add(index, item);
bean.setList(list);

But it rather does like:
bean.getList().add(index, item);
 
Dave Joseph
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bauke Scholtz wrote:It works just the same way as your parent table, the tr:table. The setter of its value, #{DocumentBean.proList}", is also never been called.

JSF EL doesn't do like the following:
List list = new List();
list.add(index, item);
bean.setList(list);

But it rather does like:
bean.getList().add(index, item);



you are the man. thank you so much for your help. i was able to accomplish what i needed with your insight.

Can you or anyone else recommend me a good reference where i can learn more about how the framework handles bindings and such? BalusC's website provides very good examples, but I am still having some issues understanding how the bindings work in depth.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My website indeed contains lot of useful JSF related resources. For an insight about the bindings in the JSF lifecycle you may find this article useful: http://balusc.blogspot.com/2006/09/debug-jsf-lifecycle.html
 
reply
    Bookmark Topic Watch Topic
  • New Topic