当在Tab1上填充InputText时按下Enter键时,我正在触发向导的next()。 InputText具有焦点并显示工具提示。导航到Tab2后,仍会显示工具提示。我的代码出了什么问题?我该怎样摆脱这种影响?
Tab1 screenshot Tab2 screenshot
JSF页面:
<h:form >
<p:panel style="width: 25%;">
<p:wizard flowListener="#{wizardBean.onFlowProcess}" style="text-align: left;"
widgetVar="testWizard">
<p:tab id="tab1" title="Tab 1">
<p:inputText id="inputText"
value="#{wizardBean.inputVal}"
title="Hit Enter to submit"
onkeypress="if (event.keyCode === 13) { PF('testWizard').next(); return false;}"/>
<p:tooltip for="inputText"/>
</p:tab>
<p:tab id="tab2" title="Tab 2">
<p:outputLabel value="Hello."/>
</p:tab>
</p:wizard>
</p:panel>
</h:form>
豆:
import java.io.Serializable;
import javax.inject.Named;
import javax.faces.view.ViewScoped;
import org.primefaces.event.FlowEvent;
@Named(value = "wizardBean")
@ViewScoped
public class WizardBean implements Serializable {
private String inputVal;
private boolean skip;
public WizardBean() {
}
public String getInputVal() {
return inputVal;
}
public void setInputVal(String inputVal) {
this.inputVal = inputVal;
}
public boolean isSkip() {
return skip;
}
public void setSkip(boolean skip) {
this.skip = skip;
}
public String onFlowProcess(FlowEvent event) {
if(skip) {
skip = false;
return "confirm";
}
else {
return event.getNewStep();
}
}
}