1 2 Previous Next 16 Replies Latest reply: Sep 3, 2009 9:13 PM by Nick Belaevski RSS

blur + rerender +focus=

Francisco Jose Peredo Noguez Master

It is a pretty simple thing, you write something in an input box, and a selectOneMenu changes its selection to match what you write in the inputbox... why do I need to do that? (because I am replicating the UI of a legacy Oracle Forms system and it works like that, and the customer likes that, so it has to work like that)

I worked pretty fine... until the customer decided to start using the keyboard (FFox 3.5/ Richfaces 3.2.2):

1) Write in the inputbox
2) Press TAB
3) rerendered selectOneMenu
4) The focus is now lost


Here some of the code:

 <h:inputText id="value" required="true"
 value="#{testSelectRerenderFocus.value}" styleClass="focused">
 <a:support event="onblur" action="#{testSelectRerenderFocus.selectValue}"
 reRender="selectOneNumberList"/>
 </h:inputText>


 <h:selectOneMenu id="selectOneNumberList" value="#{testSelectRerenderFocus.selectedValue}">
 <s:selectItems value="#{testSelectRerenderFocus.values}"
 var="item" label="#{item['name']}" itemValue="{item['id']}">
 </s:selectItems>
 </h:selectOneMenu>



The testSelectRerenderFocus.selectValue looks like this:
 public void selectValue(){
 log.info("will set selectedValue");
 this.selectedValue=value;
 log.info("selectedValue is now: #{testSelectRerenderFocus.selectedValue}");
 }


So I said, easy to fix just add focus in a:support :


<a:support event="onblur" action="#{testSelectRerenderFocus.selectValue}"
 reRender="selectOneNumberList" focus="selectOneNumberList"/>



And yes that fixed it... until the customer decided to use the mouse again!

1) Write in the inputbox
2) Click another form control (not the selectOneNumberList)
3) The focus is now in the other form control
3) rerendered selectOneMenu
4) The focus is selectOneNumberList

Of course the customer did not like that, he says that if he clicks a form control, then the focus should stay there (and, that, I have to admit, makes sense)...

Any hints?

1 2 Previous Next