This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am new to JSF and I'm having a problem with the attribute tag.
I'm trying to dynamically display a set of database tables with delete buttons adjacent to each row each table. The problem I'm having is in "relaying" to the pagecode the row deleted (and the table from which the row has been deleted) with the <f:attribute> tag:
Then, in the pagecode "Lookup.java" (which is in request scope; this request scope pagecode references the session scope instance "controller", but that is not shown here):
The problem becomes apparent when I print out the result of these two "toString()" calls: What happens is that while the "tableOfRowDeleted" correctly contains a reference to the instance associated with the table from which the user pressed the delete button on (which is the expected behavior), the "rowDeleted" reference is wrong ("wrong" as in this is not what I intended): instead, "rowDeleted"--regardless of what table the user pressed the delete button on--contains a reference to a RowEntry associated with the last table displayed in the resulting HTML page and of the same row offset (into the table).
For example, if the above code displayed two tables as follows:
COL_NAMEA | COL_NAMEB | COL_NAMEC
ROW0 COLA | ROW0 COLB | ROW0 COLC (delete button)
ROW1 COLA | ROW1 COLB | ROW1 COLC (delete button) <--- A (this button is pressed)
ROW2 COLA | ROW2 COLB | ROW2 COLC (delete button)
COL_NAMEA | COL_NAMEB
ROW0 COLA | ROW0 COLB (delete button)
ROW1 COLA | ROW1 COLB (delete button) <--- B (but the underlying reference which this row represents is erroneously retrieved in the page code)
If the user presses the delete button adjacent to the second row of the first table (labeled "A" above), then when the "doBtnInitDeleteRow()" function is executed, "rowDeleted" does not contain a reference to table 1's second row (as I would expect). Instead, "rowDeleted" contains a reference to the second row of table 2 (labeled "B" above). It so happens that in any combination of tables which I choose to display with this code, the RowEntry reference retrieved in the pagecode associated with the delete button is always associated with the last table displayed in the HTML.
Thanks for your help in advance. If this appears to be an issue with the usage of that non-standard tag (and not general JSF issue), then let me know and I'll seek help from IBM instead.