• 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

action method not invoked

 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic