• 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

Delete/edit a row in JSF

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi:

My application is a standard MVC app which uses Apache Trinidad as its front-end. A few weeks backs I posted a question about displaying buttons in a table based on a if-else condition and I was told to use DataModel and I have used it: Display_if_else_condition

Now, when I am trying to delete/edit a row, I am unable to capture the selected row in the backing bean. When I am trying to read the table using getRowData() it is returning null. Here is the code in my JSPX file:

And in the backing bean (this code is from Trinidad's dev page: Trinidad_Tables):

I need to capture the selected row - which in my application is a DTO and send it to the DAO for deletion. Can you please let me know what I am doing incorrectly here that I cannot capture the selected row? Thank you in advance for your time!

FYI, I cross-posted this question on Sun's JSF Forums as well: Cross-post_Sun_JSF_Forum

Best,
Anil.
 
Anil Gorthy
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all for attempting to provide a solution. The reason I could only see null whenever a row was selected is due to my backing bean not being in a session scope. After changing it to session from request, I was able to capture the selected row.

The relevant part in my faces-config.xml:There was also one other discussion on MyFaces - Users mailing list that was very helpful and which clarified that I should use session scope was:
[url=http://www.nabble.com/Table%27s-data-not-displayed-upon-setting-"binding"-attribute-with-tr:table-td2470023.html]MyFaces-Table-Binding[/url]

Just as an FYI, as mentioned by this user, I too have used both value="#{adminBean.names}" and binding="#{adminBean.table}".

What I have not been able to accomplish was refreshing the table whenever the delete operation is completed. Since this table is displayed only when a user selects an item in the listbox, they currently will have to select a different item in the listbox for this table to refresh. Not a pretty UI experience but I will get to it.

I have completed the Delete row part and the Edit row is pending however, retrieving the selected rows' values was the critical piece.
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Anil,
Changing scope to the session, was not the fix it was just an alternate.
So, you have assumed that for request scope bean a selected row data cannot be fetched.
 
Anil Gorthy
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rajneesh,

When that bean was placed in the session, I was able to retrieve the values of the selected row however, as you have rightly mentioned, that is a workaround. So, I will go back and convert this bean to request scope.

Thank you!

Best,
Anil.
 
Destroy anything that stands in your way. Except this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic