1 Reply Latest reply on Jun 21, 2010 1:48 PM by deanhiller2000

    nesting editable tables finally solved...

    deanhiller2000

      It's been way too long figuring out how to do nested tables and I thought I would share the solution we finally used after months of developing fickle code.  This results in much less fickle code and you don't have 5 to 8 corner cases that make it tough like we originally had when we started.


      First, do NOT use edit links for each row in the first table and then show table with edit links on the next nested table.


      Let's pretend you have scripts and questions and questions had rules.


      Step 1. Show the list of scripts with NO edit button and one add button
      Step 2. When the script is clicked, show a READ ONLY view of the script with the list of questions BUT again no edit button BUT with an add
      Step 3. on this same list of questions page, show an edit button next to the title of the script where you can start a conversation and end when they change the scripts name
      Step 4. If they click the question, show the read only of the question(use same pattern from here)
      
      Step 1 on Add.  If they click add script now, go to editscript.xhtml, and when they click save, go to read only view of the script with the Add button to add questions.
      



      Basically, we started with script page having edit link per script which started a conversation and went to editscript.xhtml which had a table of questions which had edit links....This turned out to be a very very very bad pattern and we ran into lots of issues and still have trouble with it every time we change the code.  AVOID this at all costs.  There are so many corner cases ;).  Insert read-only views and it makes the code very robust so changes don't break other code.


      Anyways, this is just my opinion from working on seam for about 1 year now with this specific scenario(our tables go about 5 deep and customers don't want to blow away all their previous results when one cancel button is clicked.  We are very very happy that this new pattern seems to be working great!!!!  and seems to be more usable as well for the user.


      later,
      Dean

        • 1. Re: nesting editable tables finally solved...
          deanhiller2000

          grrrr, so ran into one BIG problem that is solvable with this solution.  You have to make sure the urls are parameter driven such that the params help load the page AND more importantly when you click add or edit, you need to make sure the correct top level item from the top table is reloaded OR you may be adding items to the wrong top level table.


          For example.  If you have a table of Cars which each car has a table of colors(all addable/editable).  When you go to the read only car page with http://xxxxx/?car=honda, when the user clicks add color or edit car, you need to reread the car param and load it in those action methods.  Your other option is to outject it into session BUT then all hell breaks loose when a user uses two tabs and goes to a honda and then to a BMW as BMW is in the session then and clicking edit on BMW would result in editing the honda.


          I suppose there is a way to do this with page context as well somehow.  Do page params last from response to next request such that I can reinject the previous requests page params though into the action method?  (It seems like they should but I though I remember that not working once).


          I maybe could even have #{carActions.edit(car)} and in my ShowReadOnlyAction.java have




          @Scope(PAGE)
          private Car car;
          
          





          I wonder if that works as then I don't need to worry about the url at all and reloading it though I have to do mgr.find again since I just started a new conversation of course and car is detached now.


          later,
          Dean