我有一个<p:inputText value="#{beans.text}" />
和一个<p:commandButton actionlistener="#{beans.method}" />
。 如何从输入文本中的“输入”按钮执行按钮的actinoListener-Method?在InputText上为CommandButton监听器输入事件
感谢答案
财产以后出了问题。这里是代码片段 - >
<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>
如果我激发'enter'-event regexSave-Method将被执行。但是SaveOrUpdateHour的方法也是如此......
出错了。这里是代码snippet->
<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="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> ....
中有一些问题,缺的词..我想你想你说你有一个的inputText和一个命令 – Damian
输入文本与命令按钮的形式相同?只有一个命令按钮?为什么你不包含你的xhtml的片段来澄清这一点? – Damian
同时我已经配置我的代码了一点。现在文本框和按钮位于我桌子的标题中。 – Sandy