开发者

How to dynamically add input rows to JSF h:dataTable and keep focus where it was

Problem is simple. Page has some textfields and user must be able to write into as many of them as he needs. When user starts to fill last textfield then new empty开发者_开发知识库 textfield must be added.

Currently i am able to add rows with ajax but focus gets lost. Bean keeps track of total number of rows and if currently focused row is last then new item is added to list and datatable rerendered. How to keep the focus in input textfield where it was before rendering. I can also use openfaces features.

    <h:form id="myform">
        <h:dataTable id="table" value="#{ajaxTestBean.rows}" var="rows">
            <h:column>
                <h:inputHidden id="inputtext" binding="#{ajaxTestBean.input}" value ="#{rows.rownum}"></h:inputHidden>
                <h:inputText value="#{rows.text}">
                    <f:ajax event="focus" listener="#{ajaxTestBean.action}" render=":myform"></f:ajax>
                </h:inputText>
            </h:column>
        </h:dataTable>
    </h:form>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜