• 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

Call commandLink through radio button

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:


 
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
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
Try RichFaces or IceFaces, then. They'll do AJAX under JSF1.
 
fabio alonso
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
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
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic