• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using onblur with rich suggestionBox  RSS feed

 
J Miller
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • 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.
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!