• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"nested forms" in JSF?

 
Peter Berghold
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm just getting my feet wet in JSF and and I'm probably getting in over my head already.

The web application that I'm designing is going to be fairly complex in the end but here is the overview of what it is all about. This application is going to coordinate workers for dog agility trials. Workers are drawn from two sources, exhibitors that volunteer and paid workers.

The exhibitors are where I need to use some sort of "nested form" (and other places as well, but I'll use them as an example.).

When an exhibitor is looking at and editing their account information on the website I want them to be able to edit that information. So far so good, I can display their account information but here is where it gets tricky.

An exhibitor can have more than one dog. As well I want them to be able to add dogs to their information.

A single dog's information will consist of the dog's name and their jump height.

On the edit form I want to be able to list each of these dogs and provide "hooks" to be able to:
  • edit this dog (change its jump height for instance)
  • remove this dog


  • Of course, the list of dogs is going to be just that within the managed bean for the form, probably of type ArryList.

    Is there a way of doing this in JSF and/or am I overlooking the obvious?
     
    Bauke Scholtz
    Ranch Hand
    Posts: 2458
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Nesting forms is forbidden as per HTML specification. As JSF just renders HTML, it can't do much for you.

    You can just place it in a single form or in two separate forms. The Tomahawk component library has a t:subForm component which simulates nested forms with help of a shot Javascript. See if it's useful.
     
    Peter Berghold
    Greenhorn
    Posts: 7
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    That being the case, I guess I'm using the wrong terminoligy. What I'm after is for a given record

    Sally Jones
    List of dogs
    Fido Jumps: 16" [delete] [modify]
    Fluffy Jumps: 20" [delete] [modify]
    Clyde Jumps: 8" [delete] [modify]

    such that the [delete] and [modify] command buttons are specfic to the row they live in? I know some tricks I'd do in Struts, but I haven't figured out the JSF way of doing that yet....
     
    Bauke Scholtz
    Ranch Hand
    Posts: 2458
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    If you display them in a h:dataTable, you could get the associated row object using UIData#getRowData() (you only need to bind h:dataTable to an UIData property) or DataModel#getRowData() (you only need to wrap the rows in a DataModel property which you pass to h:dataTable value).

    Also see this article for extensive examples on using the h:dataTable:
    http://balusc.blogspot.com/2006/06/using-datatables.html
    [ December 17, 2008: Message edited by: Bauke Scholtz ]
     
    Peter Berghold
    Greenhorn
    Posts: 7
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks for that reply! There's a lot there for me to digest including some hints on how to accomplish a much more elusive solution to another problem I have been trying to solve.

    Another type of form I have to create has a table in it that has variable columns as well as variable rows and there is even something there that might help with that.



    Thanks again.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic