This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JSF and the fly likes commandButton in dataTable doesn't work -method not found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "commandButton in dataTable doesn Watch "commandButton in dataTable doesn New topic
Author

commandButton in dataTable doesn't work -method not found

Mark Moge
Ranch Hand

Joined: Mar 14, 2009
Posts: 96

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



SCJP6 | http://programmerutilities.blogspot.com/
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
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

Joined: Mar 14, 2009
Posts: 96

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

Joined: Oct 08, 2006
Posts: 2458
Okay, the first and the third part of my reply still stays.
Mark Moge
Ranch Hand

Joined: Mar 14, 2009
Posts: 96

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

Joined: Oct 08, 2006
Posts: 2458
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

Joined: Mar 14, 2009
Posts: 96

.
Mark Moge
Ranch Hand

Joined: Mar 14, 2009
Posts: 96

I've changed var from "customer" to "cust" and it works now . Thanks a lot.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: commandButton in dataTable doesn't work -method not found
 
Similar Threads
creating a table component dynamically
HtmlDataTable and "duplicate ID"
Which Package to Import to Use FacesContext's getRequestMap()?
JSF ArralyList rendering to Target page is throwing Class Cast Exception
Providing anchor to columns in a datatable