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 <h:commandButton not invoking its action method after enabling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "<h:commandButton not invoking its action method after enabling" Watch "<h:commandButton not invoking its action method after enabling" New topic
Author

<h:commandButton not invoking its action method after enabling

inora kumar
Greenhorn

Joined: Apr 14, 2011
Posts: 5
Hi All,
In my requirement, command button should be in disable state initially, and it will be enabled on change of dropdown box. Here the issue is after enabling the button, it’s not invoking its action method on click. But its works good if I never disable the button. I am enabling the button through <f: ajax render property. Is it a issue with <f: ajax. I have pasted the code snippets below, Please help me what I am missing in that. Thanks in advance. [i have tried immediate="true" also]


This is my XHTML:




This is my ActionBean

inora kumar
Greenhorn

Joined: Apr 14, 2011
Posts: 5
is the issue is much tricky ?
inora kumar
Greenhorn

Joined: Apr 14, 2011
Posts: 5
Enabled command button invokes its action method when i change scope from RequestScoped to SessionScoped. Why is it so? what is with ajax and scope?

Can we acheive this with request scope ?

Please show some lights on this !
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16058
    
  21

inora kumar wrote:Enabled command button invokes its action method when i change scope from RequestScoped to SessionScoped. Why is it so? what is with ajax and scope?

Can we acheive this with request scope ?

Please show some lights on this !


It's more "what is with JSF and scope". JSF relies heavily on postbacks and request scope is too short for a lot of things.

However, keeping a lot of session objects is wasteful, so JSF2 added View Scope. Try that, instead.


Customer surveys are for companies who didn't pay proper attention to begin with.
inora kumar
Greenhorn

Joined: Apr 14, 2011
Posts: 5
Thanks for your response Tim. Yes i am using ViewScope only.

But the requirement is to use Request scope only, i am colleting the points to show benefit of View scope.

if possible please add your points. thanks.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16058
    
  21

In Request scope, the data is destroyed at the end of each request and has to be re-created when the next request is made. This can be a problem when doing postbacks, especially when using things like datatables, because the tablemodel that maintains the cursor for iterating through the data rows is destroyed, as is the datamodel itself.

In Session scope, the data is retained between requests, so that's not a problem.

These two scopes are an integral part of J2EE and have been for years.

Session scope, however, is basically forever - or at least until the session scope object is detached from the HttpSession object (or the session is destroyed). Since JSF doesn't really support destruction of scope objects, that means that you can end up with a lot of objects cluttering up your app environment and wasting resources.

In JSF2, the View scope was added. Unlike Request and Session scopes, it's not directly provided by the J2EE server. Instead, it's a session object with a built-in destruct mechanism that removes the object from the session once you transfer to another View.
Guy deLyonesse
Ranch Hand

Joined: Apr 12, 2011
Posts: 200

Maybe I'm misunderstanding the syntax on this, since I don't use f:ajax I'm more of an ICEfaces kind of guy, but should the render attribute be "rendered?" And should it be set to "true" or "false" such that changing it dynamically would mean tying it to the EL?



With the bean having some code to change the value of the showButton member based on a value change listener attached to the dropdown box?
Vadym Baranenko
Greenhorn

Joined: Oct 06, 2010
Posts: 18
inora kumar wrote:Thanks for your response Tim. Yes i am using ViewScope only.

But the requirement is to use Request scope only, i am colleting the points to show benefit of View scope.

if possible please add your points. thanks.


Or you can just use javaScript to enable the button
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: <h:commandButton not invoking its action method after enabling