File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes action method not invoked Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "action method not invoked" Watch "action method not invoked" New topic
Author

action method not invoked

Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
I have a managed bean with request scope with a jump() method

and here is my jsf:-

When I press the "Jump" button, i get the text "Jump method invoked" in my console (GOOD)

Now, I just changed the jsf as follows :- added a rendered attribute to the "jump" button



Now, when I first visit the page (currentItems is empty), so the Jump button is not displayed. I press the "some" button, which invokes the someMethod() function (which sets the currentItems to a dummy list and redisplays the page).

Now the jump button is visible, but when I press it, nothing happens. ie., I do not get the text "Jump method invoked" in my console.

What could be wrong?


MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16308
    
  22

Jump shouldn't return null. Return some sort of a (non-empty) string, even if it's a dummy one. Just to say you did, if for no other reason.

The string you return is used by the navigation facility to determine what view to display next. If nothing matches a rule, you get the same view that you had last time. But it's a little tidier if the string being examined by the navigator should be a real, visible value. While I don't know that the spec demands it, sooner or later someone will probably implement a tracing facility and it will be easier to see where you're going if there's actually a return value that can be seen.


Customer surveys are for companies who didn't pay proper attention to begin with.
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
Thanks Tim. But that did not help.

Someone pointed to me on another forum that


Probably another scoping issue.

The button is now visible yes because at the time when this rendered attribute was evaluated.. (after someMethod() was invoked) it evaluated to true.. now the page redisplays with the button.. the Response has been written. when hitting the button. the rendered attribute evaluates to false since the currentItems list is now null or has changed size. The rendered attribute is actually doing more then saying show or don't show the button.. since it evaluated to false after you clicked the button.. the action will not get invoked.

Basically the moral of the story. since we are dealing with request scope beans here is you need to find away to persist that list "across the request" for which the rendered attribute of the button is evaluating.

Using request scope is good.. but difficult in this environment for sure.
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
Got around the issue :-

Added the following method to my managed bean:



and in my jsf page



I am not too happy with this workaround, but hey! it works. I can live with it.
JR Yalbets
Greenhorn

Joined: Oct 31, 2006
Posts: 5
Changing your backing bean from request scope to session scope will fix the problem. Request scope may be preferred, but most backing beans need to be in session scope in order for the jsp page to work correctly (depending on what you are doing).
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
No, unfortunately I cannot have session scope for my backing bean. My backing bean is used for performing a search and one of the requirement is to run multiple searches in parallel (ie., by opening a new browser window), which i believe cannot be achieved using session scope.
JR Yalbets
Greenhorn

Joined: Oct 31, 2006
Posts: 5
You could try leaving the backing bean in session scope, but then add the bean to the request before opening the new window. You could also remove the backing bean from session at that point if it's no longer needed. That may solve both issues depending on what it is you are trying to accomplish.
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
Have you tried to use rendered on <h:panelGroup> control?

rendered with same criteria that you were using on button control
[ November 01, 2006: Message edited by: Ali Gohar ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: action method not invoked