• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Client side rendeing

 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi every body I have a query ,
is it possible to client side rendering in the JSF ?

Here I am describing what I want,
I have two radio buttons say radio1 & radio2 , these two radio buttons are independent with each other .
When user click the radio1 then page will render and show some fields below the radio1 .
Same if user click radio2 some fields will get render show below the radio2 , currently I have achived this by using the panelGrid's render
property , each and evry call I am going to the server & making the render property true / false & showing the proper fields .
My question is, is this possible in the client side , without rendering in the server trip ?

thanks and regards,
S


 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can accomplish that with ajax. Ajax4jsf is an easy to use library for JSF, that allows you to execute (server-side) java code when a javascript event occurs (such as onchange, onclick, etc.) and rerender part of the browser-view. Technically, still a server-call is made, but since the only a portion of the browser-view is redrawn, the effect is the same as you would have with client-side javascript only.
Ajax4jsf is integrated with the jsf library richfaces, but can be used apart from richfaces too.
The richfaces library has also a few controls such as togglepanel and jtree that can render part of the content completely client-side, so that for example no server-call is needed when the user switches a panel or opens a tree-item.

See: Richfaces developer guide and Ajax4jsf
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply ,
but my problem is something different ,
here I am try to describe the problem :
i have two radio say , radio1 and radio2.When user click the radio1 one field will get render below the radio1,
after that if user select radio2 the field that got render below radio1 will not show in the page & a new field will get render
below radio2 .
How could I control two different rendering in the client side ?

regards,
S
 
Saloon Keeper
Posts: 28713
211
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
Visualize it like this:



I'm keeping to DHTML terms, since that's what the JSF has to produce on the browser side, but by using an AJAX-aware tag library such as RichFaces, you can do the same thing at a more abstract level. DIV1 and DIV2 are simply blocks of dependent controls and display items. A 1-column panelGrid is a reasonable JSF equivalent. Or more than 1 columns, if you have more complex layout.

Essentially, the "oncheck" function for Radio Button 1 should set the "visible" attribute of DIV1 to "true" and the "visible" attribute of DIV2 to "false". And the reverse, for Radio Button 2.

If there's no need to inform the backing bean, you can do all this in JavaScript. If you need to update the backing bean, use AJAX, like Gerbrand said. In that case, you can use a "rendered" attribute to show/hide DIV1 and DIV2. For example:

 
reply
    Bookmark Topic Watch Topic
  • New Topic