• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Using onblur with rich suggestionBox

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a rich suggestionBox that needs to not only function as a normal suggestion box, but if the user types something quickly and tabs out of the text box before the suggestions appear, it should just save whatever they entered. I’ve tried doing this a few different ways, but every different way seems to have different bugs that go along with it. It’s important that it saves when they tab out of the box, because other text fields and suggestionBoxes will be filtered to only include records that align with what was chosen in previous boxes.

I think the ideal solution would be to just call an a4j jsFunction using the onblur event. The problem with that, is that if you DO wait for the suggestions to appear, clicking on the suggestion box scroll bar triggers the onblur, and it saves the partial match, reRenders the panel and closes the suggestions. I thought then that if I called a JavaScript function that checked the focus, I could see if the suggestionBox has focus, and if it does, I could do nothing. If it does not have the focus, then the user has clicked on and I could save it. Problem is, I can’t figure out how to do that. I’m using:

document.activeElement.id

to get the ID of the element which has focus. This works with every text box or button, but the suggestionBox doesn’t appear to have an ID. I’ve tried specifying an ID on the rich suggestionBox, on the h column that contains the results, and on the outputText for the results. Each time, the ID I get is empty.

Anybody have any ideas as to how I can accomplish this?

I'm using JSF 1.2 and RichFaces 3.3.3.
 
Saloon Keeper
Posts: 28319
210
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
Despite what its name implies, the RichFaces suggestionBox isn't a control, it's a modifier for another control - typically an inputText control. The relevant ID belongs to that control, not the suggestionBox element.

What I do is put an aj4:support for the onblur event of the inputText control.
 
J Miller
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've tried that, but what ends up happening is if you have enough suggestions to have a scroll bar, clicking on that scroll bar in the suggestionBox triggers the onblur. For some of these fields, when a selection is made I'm reRendering other sections. So if you click the scroll bar, the suggestionBox goes away.
 
Tim Holloway
Saloon Keeper
Posts: 28319
210
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
I'm hoping RichFaces 4 addresses some of these quirks. Right now it's sort of a treasure hunt making the suggestionbox well-behaved.
 
permaculture is giving a gift to your future self. After reading this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic