• 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

JSF 2.0 - Ajaxification of listboxes and menus

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, so far so good, I've made quite a lot of progress with JSF 2.0, but now I'm getting to a particularly important part involving Ajax, which I'm having trouble understanding.

The code without using Ajax works, but it causes irritating page "flips" and messes up the display, and I wish to use Ajax to get rid of that.

The relevant part of the xhtml file is as follows:

where I specify a menu where you can select one out of several options. Once you have decided which option you want, you click <h:commandButton> "Select Set", which fires
an action listener that then downloads from an external file the data you want, which is then used to set up a second menu. The reason why I have chosen to use a command
button once you have selected an option is because a file is downloaded, and I don't want a file to be downloaded every time you change the selection, only when you
specifically want it. <h:commandButton> comment A controls the values given by comments a, but I would like this to be done by Ajax.

Once you have downloaded data, it appears in a second menu in <h:selectOneListbox>, and you can make changes to selected values by inputting text in <h:inputText>, then
<h:commandButton> "Update Abundance" will copy the value in <h:inputText> to the selected place in <h:selectOneListbox>, i.e. <h:commandButton> comment C controls comments c.
Again I would like this to use Ajax.

Finally <h:button> "Readme", comment B, displays a popup using JavaScript, and does not have any associated code in a bean, but also causes an irritatiing page flip.

The code in my bean is as follows, where "a", "A", "c" and "C" correspond to the code in the xhtml file:

The basic question is how to "Ajaxify" the code in a suitable way. Any ideas and suggestions would be most appreciated.
 
Ranch Hand
Posts: 514
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Christopher!

I don't think it is good to put so long code and many questions in one post. Better understandable is to put simple question or a few easy to answer questions.
Because the long time should be spent to realize something and I stiil don't understand all your post

As I see you want to do similar to what I did a few weeks ago. As abundanceSet0 is selected corresponding list for abundances0 is constructed.
Together with Tim Holloway I did:

In backing bean I have:

When value of first selectonemenu 'countryGroup' changes this is working
<f:ajax execute="@this" event="change" render="registerForm:regionGroup" />
And this causes to work this
valueChangeListener="#{registerBacking.showRegions}"
After registerBacking.showRegions f:ajax renders registerForm:regionGroup which causes method getRegionSelectItems to look in database for new regions based on new country
Follow this approach. Probably it is what you need!
 
Christopher Sharp
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Volodymyr,

Many thanks indeed for your detailed reply, and I'm sure it will be very helpful, particularly as you gave me an example which is similar to my problem. I agree with you that I put in too much information at once, which may have caused some confusion, and should have asked a question about one specific problem at a time.

Basically, I wanted to get the application working without Ajax in the first instance, then put in Ajax to make it work much better. The original version of my code can be found by going first to:

http://phoenix.ens-lyon.fr/simulator/

then clicking "MODEL SPECTRA", then clicking "Continue" on the lower left. Most of this was originally written using JavaScript before I knew what server-side code to use, then later decided to use JSF 1.2. Because I already had a lot of JavaScript, I just "bolted in" JSF 1.2 using some additional buttons and hidden fields. Now I am completely rewriting this using JSF 2.0 and want to use as little JavaScript as possible.

I am also seriously thinking of using PrimeFaces, and have played around with some simple tests, but first I need to get some experience with Ajax.
reply
    Bookmark Topic Watch Topic
  • New Topic