• 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

AJAX Conditionally Render Components

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to use the RichFaces AJAX library with a JSF application. I want to conditionally render a couple <h:inputText> entries based on the value of a drop down menu. How do I do that? Here's my code so far:

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to ask JSF questions in the JSF forum. I have moved this post there for you.
 
Andy Holm
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got this to work by using the code at the bottom of this post. The problem I now have is that when the reRender happens, the browser scrolls to the top of the page rather than remembering where it was before the reRender. Any ideas on how I can prevent that from happening? I tried following this example, but it didn't work for me in IE 7: http://blogs.x2line.com/al/articles/156.aspx

 
Andy Holm
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyone able to help on this?
 
Andy Holm
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, after some tinkering, I was able to remember the scroll position via a cookie. Now, the last remaining question I have is how do I save inputted data to my beans before the AJAX reRender completes. Whenever the AJAX reRender happens, I lose all data that has already been input into the form. The backing beans don't seem to be updated when an AJAX reRender happens like they would be on a normal page submit...
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no other go other than submitting the page....
 
Andy Holm
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I find it hard to believe that an AJAX reRender would force the entire form to lose its inputted values without a workaround. There must be a way around this; otherwise, no developer would ever use an AJAX reRender unless it is updating the entire page when any inputted data is involved.
 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Andy Holm wrote:I find it hard to believe that an AJAX reRender would force the entire form to lose its inputted values without a workaround. There must be a way around this; otherwise, no developer would ever use an AJAX reRender unless it is updating the entire page when any inputted data is involved.



Ajax rerender does not and should not cause you to lose any form data, think logically, you are sending the request to the server and the server only refreshes/rerenders output for only those elements specified in reRender , it does not touch the other output/data

Debug to see what is causing the form to lose data
 
Andy Holm
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any idea on how to debug this?
 
Andy Holm
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a simplied full example that should allow you to duplicate the problem. What am I doing wrong?



Bean:
 
Andy Holm
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was able to get most of the values to save on the reRender by extending the a4j region. The one exception is this value:



Any ideas on how to store this value on an AJAX reRender? Sometimes I think I am talking to myself on this forum... lol
 
Kavita Tipnis
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This post should answer that last question
Problem with t:inputFileUpload
 
This one time, at bandcamp, I had relations with a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic