【问题标题】:Save p:inplace with enter key使用回车键保存 p:inplace
【发布时间】:2019-05-08 10:16:22
【问题描述】:

我已经添加了 primefaces inputtext with inplace 通过双击只读文本来获得只读和编辑文本。仅当我在编辑器模式下单击勾选图标时,inplace 事件才会触发 ajax 侦听器。

我在下面的链接中使用了这个作为 primefaces 展示的参考

https://www.primefaces.org/showcase/ui/input/inplace.xhtml

<p:inplace id="stackSetDesc" editor="true">
  <p:ajax event="save" listener="#{stackEditBean.updateStackSet()}"                         process="@this" update="@form" />
  <p:inputText value="#{stackEditBean.stackSetDesc}" required="true" label="text">                          
</p:inputText>
</p:inplace>

如何在编辑文本后通过调用回车按钮触发相同的就地监听方法

【问题讨论】:

标签: primefaces


【解决方案1】:

我就这样解决了

<p:treeNode>
    <p:inplace widgetVar="inplace_#{node.rowKey}" editor="true">
        <p:inputText value="#{category.categoryName}" required="true" label="text" onkeydown="if(event.keyCode==27) {PF('inplace_#{node.rowKey}').cancel(); return false;} if(event.keyCode==13) {PF('inplace_#{node.rowKey}').save(); return false;}" />
    </p:inplace>
</p:treeNode>

【讨论】:

    【解决方案2】:

    我通过下面的代码得到了应得的操作

      <p:inplace id="stackSetDesc" editor="true">
                                        <p:ajax event="save" listener="#{stackEditBean.updateStackSet()}"
                                            process="@this" update="@form"
                                            onstart="PF('loadWidget').show();"
                                            onsuccess="PF('loadWidget').hide();" />
                                        <p:inputText value="#{stackEditBean.stackSetDesc}"
                                            required="true" label="text"
                                            requiredMessage="Description cannot be empty , Please Enter Name"
                                            onkeypress="if (event.keyCode == 13) { saveStackSetID(); return false; }" />
                                    </p:inplace>
                                    <p:remoteCommand name="saveStackSetID" update="stackSetDesc"
                                        actionListener="#{stackEditBean.updateStackSet()}"
                                        onstart="PF('loadWidget').show();"
                                        oncomplete="PF('loadWidget').hide();">
        </p:remoteCommand>
    

    【讨论】:

      猜你喜欢
      • 2015-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多