-
1. Re: Textfield looses focus during reRendering - how to avoid
ilya_shaikovsky Jul 6, 2007 7:50 AM (in response to orribl)Works as expected :) input which was focused - deleted from the DOM and inserted again. So scroll lost.
The solution is to use "focus" attribute which should be defined as id of the component that should get focus after request completed. -
2. Re: Textfield looses focus during reRendering - how to avoid
orribl Jul 6, 2007 8:01 AM (in response to orribl)I don't know how to provide the componente with a unique id...
When i try to use an attribute from the field object i get the error:component identifier must not be a zero-length String
What version of ajax4jsf/myfaces? are you using? -
3. Re: Textfield looses focus during reRendering - how to avoid
ilya_shaikovsky Jul 6, 2007 8:05 AM (in response to orribl)you need to specify the id as id="someId"
-
4. Re: Textfield looses focus during reRendering - how to avoid
orribl Jul 6, 2007 8:13 AM (in response to orribl)Hi ilya_shaikovsky,
I don't know how to do that...
For example, I have 10 fields in my fields-array, the only way how to provide each field with a unique id is to read some attribute from the field-object.
I can't just write id="unique" cause i loop through the array to create the fields...
So if i would write:<h:column rendered="#{field.render}"> <h:inputText id="unique" value="#{field.value}"> <a4j:support focus="unique" reRender="sumFields" event="onkeyup"/> </h:inputText> </h:column>
gives all textfields the same id.
But when I try something like:<h:column rendered="#{field.render}"> <h:inputText id="#{field.unique}"value="#{field.value}"> <a4j:support focus="#{field.unique}" reRender="sumFields" event="onkeyup"/> </h:inputText> </h:column>
the errorjava.lang.IllegalArgumentException: component identifier must not be a zero-length String
occurs... -
5. Re: Textfield looses focus during reRendering - how to avoid
ilya_shaikovsky Jul 6, 2007 8:22 AM (in response to orribl)1) id could not be EL binded
h:inputText id="unique" value="#{field.value}">
is the right way - it will be unique because the row id will be added by column. -
6. Re: Textfield looses focus during reRendering - how to avoid
orribl Jul 6, 2007 8:52 AM (in response to orribl)Its strange, I tried a simplified example:
<a4j:outputPanel>
<h:inputText id="tmp">
<a4j:support focus="tmp" reRender="sumFields" event="onkeyup" />
</h:inputText>
</a4j:outputPanel>
It worked with firefox, but not with the ie...
The other example with the datatable doesn't work at all, also when i define an id...
What version of ajax4jsf / myfaces are you using...?
Thanks -
7. Re: Textfield looses focus during reRendering - how to avoid
sergeysmirnov Jul 6, 2007 11:13 AM (in response to orribl)The only one workaround is DO NOT update itself.
-
8. Re: Textfield looses focus during reRendering - how to avoid
orribl Jul 9, 2007 4:58 AM (in response to orribl)Hi SergeySmirnov,
do you have any idea how to do that? My first idea was to add an actionListener to the a4j:support-Tag:<a4j:support event="onkeyup" actionListener="#{sessionBackingBean.checkSpartenField}" reRender="#{sessionBackingBean.reRenderFields}"/>
and wire the reRender-Value with an ArrayList in my Backing Bean.
After that I wanted to read the id from the Component which caused the action-event and exclude this component from rendering:public void checkSpartenField(ActionEvent e){ //ArrayList with ids for the component which should be rendered this.reRenderFields = new ArrayList(); //Get the trigger of the event UIComponent parent = ((UIComponent)e.getSource()); //Get the dataTable UIComponent table = ((UIComponent)e.getSource()).getParent().getParent().getParent().getParent().getParent();
Up to this point everything works fine, but when I try now to acces the rows, I don't know how I can acchieve this cause I can only acces the static component tree...
Any ideas...? -
9. Re: Textfield looses focus during reRendering - how to avoid
orribl Jul 11, 2007 9:12 AM (in response to orribl)Nobody an idea how to solve that problem?
So I'm assuming that it's not possible to focus the field after it is reRendered...