Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Call commandLink through radio button  RSS feed

 
fabio alonso
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I created a few options with radio buttons, they call my bean and runs beauty

I have a button to update the data on the screen after I select a radio, problem is that I would call this just by changing the options button of the radiobutton or selecting any of them (no need to click the refresh button on commandLink

code radio:



code commandLink:


 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSF runs on HTTP, and HTTP's design, regardless of the framework or programming language used, is limited to request/response. When using input controls such as radio buttons, the request has to be part of a submitted form. Technically, therefore, a button cannot "call" a bean method. In fact, even "Submit" buttons don't actually "call" anything. What they do is submit the form and JSF parses the incoming data as part of its lifecycle processing, firing the control's action method (and/or notifying action listeners) as part of the lifecycle process.

Briefly, then, in order to emulate an interactive GUI desktop-style radio button action, you can't use basic JSF because it's based on basic HTML/HTTP.

However, you can use AJAX to get the desired behavior.

What you need to do is attach an AJAX request to the radiobutton. That AJAX request would then fire a backing bean method which would use the current value of the property named "codigo" to setup the updated display values. On return from the AJAX call, the changed parts of the page are re-rendered using the updated values from the backing bean.

How you handle AJAX depends on you. In JSF2, there's a new ajax tag, but a number of the third-party extension tagsets also provide AJAX services, and several of them work under JSF1 as well as JSF2.
 
fabio alonso
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:JSF runs on HTTP, and HTTP's design, regardless of the framework or programming language used, is limited to request/response. When using input controls such as radio buttons, the request has to be part of a submitted form. Technically, therefore, a button cannot "call" a bean method. In fact, even "Submit" buttons don't actually "call" anything. What they do is submit the form and JSF parses the incoming data as part of its lifecycle processing, firing the control's action method (and/or notifying action listeners) as part of the lifecycle process.

Briefly, then, in order to emulate an interactive GUI desktop-style radio button action, you can't use basic JSF because it's based on basic HTML/HTTP.

However, you can use AJAX to get the desired behavior.

What you need to do is attach an AJAX request to the radiobutton. That AJAX request would then fire a backing bean method which would use the current value of the property named "codigo" to setup the updated display values. On return from the AJAX call, the changed parts of the page are re-rendered using the updated values from the backing bean.

How you handle AJAX depends on you. In JSF2, there's a new ajax tag, but a number of the third-party extension tagsets also provide AJAX services, and several of them work under JSF1 as well as JSF2.




Thanks,

but, I'm used jsf 1.0 ......"f:ajax"....is JSF 2
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try RichFaces or IceFaces, then. They'll do AJAX under JSF1.
 
fabio alonso
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:Try RichFaces or IceFaces, then. They'll do AJAX under JSF1.




But the problem is, this is because the radiobutton in a panelGrid and commandLink in another .. how to solve this? because I can not change them from their "grids."?
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Being in separate grids is not a problem. Being in separate forms would be, because only the control values of the form containing the commandLink will be affected when you trigger the command.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!