Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

<h:commandButton not invoking its action method after enabling

 
inora kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is the issue is much tricky ?
 
inora kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
inora kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 200
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic