Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

commandButton in dataTable doesn't work -method not found

 
Mark Moge
Ranch Hand
Posts: 100
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone! I am new in JSF world and can't find a solution to my problem.

I have a dataTable with data from DB(int id, varchar name, int phone ). In 4th column i have button and I don't have any idea how to write a method which take data from the table and send them to other site for example edit.jsp . I tried:


just to change page, but always had "javax.servlet.ServletException: #{customer.send}: javax.el.MethodNotFoundException: Method not found: {ID=1, NAME=marek, PHONE=997}.send()" I want send data to other page then edit them and save in database. If someone can help me i will be very grateful.
index.jsp


faces-config.xml


CustomerBean.java


 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the bean is request scoped, you need to preserve the same datamodel for the subsequent request.
Marek Moge wrote:


This expects a public String woo() in the Customer object.
Marek Moge wrote:


This is completely out of the scope of the datatable. There is no Customer object here.
 
Mark Moge
Ranch Hand
Posts: 100
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I know that. I made a mistake and past a wrong code. Anyway I changed the code in first post and method send() works out of dataTable but in throws error.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, the first and the third part of my reply still stays.
 
Mark Moge
Ranch Hand
Posts: 100
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ad 1.the scope of bean is session
<managed-bean-scope>session</managed-bean-scope>

ad 3. this method is from CustomerBean class and works fine out of the dataTable.

Maybe i ask wrong question. Do you know how to write a method which takes data from this table

for example id=2, name="Mark" phone=998, changes page to edit.jsp and prints them by clicking the second button.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, now I see

You gave the row object instance the same name as the managed bean! Give one of them a different name so that JSF knows which bean it should have.
 
Mark Moge
Ranch Hand
Posts: 100
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
.
 
Mark Moge
Ranch Hand
Posts: 100
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've changed var from "customer" to "cust" and it works now . Thanks a lot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic