Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
User interface 在CommandButton侦听器的InputText上输入事件_User Interface_Jsf 2_Primefaces - Fatal编程技术网

User interface 在CommandButton侦听器的InputText上输入事件

User interface 在CommandButton侦听器的InputText上输入事件,user-interface,jsf-2,primefaces,User Interface,Jsf 2,Primefaces,我有一个和一个。 如何通过输入文本中的“回车”从按钮执行ActionListener方法 谢谢你的回答 出了点问题。下面是代码片段-> <h:panelGrid columns="2"> <p:commandButton actionListener="#{hoursView.saveOrUpdateHour}" /> <p:commandButton actionListener="#{hoursView.onFilterChange()}" oncomplete

我有一个
和一个
。 如何通过输入文本中的“回车”从按钮执行ActionListener方法

谢谢你的回答

出了点问题。下面是代码片段->

<h:panelGrid columns="2">
<p:commandButton actionListener="#{hoursView.saveOrUpdateHour}" />
<p:commandButton actionListener="#{hoursView.onFilterChange()}" oncomplete="dlgHoursFilter.show()" immediate="true" update=":hoursFilter" />
</h:panelGrid>
</h:panelGrid>
<h:panelGrid columns="4" class="buttonContent" id="buttonView">
<p:commandButton ajax="false" actionListener="#{hoursView.showDay()}" immediate="true" update="hoursList" />
<p:commandButton  ajax="false" actionListener="#{hoursView.showWeek()}" immediate="true" update="hoursList" />
<p:commandButton  ajax="false" actionListener="#{hoursView.showMonth()}" immediate="true" update="hoursList" />
<p:commandButton  ajax="false" actionListener="#{hoursView.showAll()}" immediate="true" update="hoursList" />
</h:panelGrid>
         <h:panelGrid columns="3" id="tableGrid">
            <p:dataTable id="hoursList" value="#{hoursView.listHours}"
                var="hours" widgetVar="hoursTable" resizableColumns="true"
                emptyMessage="#{msg.noData}" rowKey="#{hours.id}"
                selection="#{hoursView.selected}" selectionMode="single">

                <p:ajax event="rowDblselect" update=":hourEditDialog"
                    listener="#{hoursView.onHourSelect}"
                    oncomplete="dlgHourEdit.show()" />

                <f:facet name="header">
                    <h:panelGrid columns="3" class="buttonContent" id="regexContent">
                        <h:outputText value="#{msg.regexHour}" />
                        <p:inputText value="#{hoursView.regex}" id="regex">
                        </p:inputText>
                        <p:commandButton icon="addButton" id="regexSave"
                            process="regexContent" actionListener="#{hoursView.regexSave}"
                            update=":editContent:hoursList,:editContent:growl,regex">
                            <p:defaultCommand target="regexSave" scope="regexContent" />
                        </p:commandButton>
                        <p:tooltip for="regexSave" value="#{msg.regexSave}"
                            showEffect="fade" hideEffect="fade" />
                    </h:panelGrid>
                </f:facet>
<h:panelGrid columns="2">
<p:commandButton actionListener="#{hoursView.saveOrUpdateHour}" />
<p:commandButton actionListener="#{hoursView.onFilterChange()}" oncomplete="dlgHoursFilter.show()" immediate="true" update=":hoursFilter" />
</h:panelGrid>
</h:panelGrid>
<h:panelGrid columns="4" class="buttonContent" id="buttonView">
<p:commandButton ajax="false" actionListener="#{hoursView.showDay()}" immediate="true" update="hoursList" />
<p:commandButton  ajax="false" actionListener="#{hoursView.showWeek()}" immediate="true" update="hoursList" />
<p:commandButton  ajax="false" actionListener="#{hoursView.showMonth()}" immediate="true" update="hoursList" />
<p:commandButton  ajax="false" actionListener="#{hoursView.showAll()}" immediate="true" update="hoursList" />
</h:panelGrid>
<h:panelGrid columns="3">
<h:outputText value="#{msg.regexHour}" />
<p:inputText value="#{hoursView.regex}" id="regex">
<p:ajax event="change" update="hoursList, growl" listener="#{hoursView.regexSave}" />
</p:inputText>
<p:commandButton  actionListener="#{hoursView.regexSave}" update="hoursList, growl" />
</h:panelGrid>

如果我触发“enter”-事件,将执行regexSave方法。但是saveOrUpdateHour的方法也是


出了点问题。下面是代码片段->

<h:panelGrid columns="2">
<p:commandButton actionListener="#{hoursView.saveOrUpdateHour}" />
<p:commandButton actionListener="#{hoursView.onFilterChange()}" oncomplete="dlgHoursFilter.show()" immediate="true" update=":hoursFilter" />
</h:panelGrid>
</h:panelGrid>
<h:panelGrid columns="4" class="buttonContent" id="buttonView">
<p:commandButton ajax="false" actionListener="#{hoursView.showDay()}" immediate="true" update="hoursList" />
<p:commandButton  ajax="false" actionListener="#{hoursView.showWeek()}" immediate="true" update="hoursList" />
<p:commandButton  ajax="false" actionListener="#{hoursView.showMonth()}" immediate="true" update="hoursList" />
<p:commandButton  ajax="false" actionListener="#{hoursView.showAll()}" immediate="true" update="hoursList" />
</h:panelGrid>
         <h:panelGrid columns="3" id="tableGrid">
            <p:dataTable id="hoursList" value="#{hoursView.listHours}"
                var="hours" widgetVar="hoursTable" resizableColumns="true"
                emptyMessage="#{msg.noData}" rowKey="#{hours.id}"
                selection="#{hoursView.selected}" selectionMode="single">

                <p:ajax event="rowDblselect" update=":hourEditDialog"
                    listener="#{hoursView.onHourSelect}"
                    oncomplete="dlgHourEdit.show()" />

                <f:facet name="header">
                    <h:panelGrid columns="3" class="buttonContent" id="regexContent">
                        <h:outputText value="#{msg.regexHour}" />
                        <p:inputText value="#{hoursView.regex}" id="regex">
                        </p:inputText>
                        <p:commandButton icon="addButton" id="regexSave"
                            process="regexContent" actionListener="#{hoursView.regexSave}"
                            update=":editContent:hoursList,:editContent:growl,regex">
                            <p:defaultCommand target="regexSave" scope="regexContent" />
                        </p:commandButton>
                        <p:tooltip for="regexSave" value="#{msg.regexSave}"
                            showEffect="fade" hideEffect="fade" />
                    </h:panelGrid>
                </f:facet>
<h:panelGrid columns="2">
<p:commandButton actionListener="#{hoursView.saveOrUpdateHour}" />
<p:commandButton actionListener="#{hoursView.onFilterChange()}" oncomplete="dlgHoursFilter.show()" immediate="true" update=":hoursFilter" />
</h:panelGrid>
</h:panelGrid>
<h:panelGrid columns="4" class="buttonContent" id="buttonView">
<p:commandButton ajax="false" actionListener="#{hoursView.showDay()}" immediate="true" update="hoursList" />
<p:commandButton  ajax="false" actionListener="#{hoursView.showWeek()}" immediate="true" update="hoursList" />
<p:commandButton  ajax="false" actionListener="#{hoursView.showMonth()}" immediate="true" update="hoursList" />
<p:commandButton  ajax="false" actionListener="#{hoursView.showAll()}" immediate="true" update="hoursList" />
</h:panelGrid>
<h:panelGrid columns="3">
<h:outputText value="#{msg.regexHour}" />
<p:inputText value="#{hoursView.regex}" id="regex">
<p:ajax event="change" update="hoursList, growl" listener="#{hoursView.regexSave}" />
</p:inputText>
<p:commandButton  actionListener="#{hoursView.regexSave}" update="hoursList, growl" />
</h:panelGrid>

如果我触发“enter”-事件,将执行regexSave方法。但是saveOrUpdateHour的方法也是


同时,我对代码进行了一些配置。现在,textfield和button位于我表格的标题中

    <h:panelGrid columns="3" id="tableGrid">
            <p:dataTable id="hoursList" value="#{hoursView.listHours}"
                var="hours" widgetVar="hoursTable" resizableColumns="true"
                emptyMessage="#{msg.noData}" rowKey="#{hours.id}"
                selection="#{hoursView.selected}" selectionMode="single">

                <p:ajax event="rowDblselect" update=":hourEditDialog"
                    listener="#{hoursView.onHourSelect}"
                    oncomplete="dlgHourEdit.show()" />

                <f:facet name="header">
                    <h:panelGrid columns="3" class="buttonContent" id="regexContent">
                        <h:outputText value="#{msg.regexHour}" />
                        <p:inputText value="#{hoursView.regex}" id="regex">
                        </p:inputText>
                        <p:commandButton icon="addButton" id="regexSave"
                            process="regexContent" actionListener="#{hoursView.regexSave}"
                            update=":editContent:hoursList,:editContent:growl,regex">
                            <p:defaultCommand target="regexSave" scope="regexContent" />
                        </p:commandButton>
                        <p:tooltip for="regexSave" value="#{msg.regexSave}"
                            showEffect="fade" hideEffect="fade" />
                    </h:panelGrid>
                </f:facet>   ....

....

您可以使用
p:inputText
onkeypress
,在jquery的帮助下调用
。单击按钮上的()
,注意
返回false
将确保在按下enter键后不会调用任何东西(例如,
p:ajax

像这样:

<p:commandButton id="myButtonID" actionlistener="#{beans.method}" />


<p:inputText value="#{beans.text}" onkeypress="if (event.keyCode == 13) { jQuery('#myButtonID').click(); return false;}"/>


更新
代替
:editContent:hoursList
尝试
update=“tableGrid”
(请参阅表格包装器),或者如果您使用的是primefaces 3.4,请尝试
update=“hoursList”

您可以使用
p:inputText
onkeypress
,并在jquery的帮助下调用
。单击按钮上的(),注意
返回false
将确保在按下enter键后不会调用任何东西(例如,
p:ajax

像这样:

<p:commandButton id="myButtonID" actionlistener="#{beans.method}" />


<p:inputText value="#{beans.text}" onkeypress="if (event.keyCode == 13) { jQuery('#myButtonID').click(); return false;}"/>


更新
请不要使用
:editContent:hoursList
尝试
update=“tableGrid”
(请参阅表格包装器),或者如果您使用的是primefaces 3.4,请尝试
update=“hoursList”

问题中缺少一些单词。。我猜你想说你有一个inputText和一个commandButton输入文本和commandButton的形式是一样的?只有一个命令按钮?为什么不包含xhtml的一段代码来澄清这一点呢?同时,我对代码进行了一些配置。现在文本字段和按钮在我的表格标题中。问题中缺少一些单词。。我猜你想说你有一个inputText和一个commandButton输入文本和commandButton的形式是一样的?只有一个命令按钮?为什么不包含xhtml的一段代码来澄清这一点呢?同时,我对代码进行了一些配置。现在textfield和button位于我的表的标题中。我已经对它进行了测试。只有在我删除commandButton更新中的“:editContent:hoursList”时,它才起作用…如果我删除我的表,它将不会用新数据刷新…什么表?您应该更新问题中的代码,然后。。。在更新表格的位置看不到任何
:editContent:hoursList
?使用update tableGrid和update hoursList测试您的想法,但两者都不起作用。对呼叫计数没有区别。。。你说提高你的入学率是什么意思?对不起,我是新来的,我要测试一下。只有在我删除commandButton更新中的“:editContent:hoursList”时,它才起作用…如果我删除我的表,它将不会用新数据刷新…什么表?您应该更新问题中的代码,然后。。。在更新表格的位置看不到任何
:editContent:hoursList
?使用update tableGrid和update hoursList测试您的想法,但两者都不起作用。对呼叫计数没有区别。。。你说提高你的入学率是什么意思?我是新来的对不起