我的命令链接仅在第二次点击时调用操作。我添加了一个调试点并试过了。首先点击它不会来方法。只需点击二次即可点击该操作。 我尝试添加here中提到的脚本,但没有帮助。还有其他解决办法吗?而是h:commandlink?
<h:form>
<h:panelGroup id="new-line-panel">
some code goes here....
<h:panelGroup id="numberSelectionPanel">
<ui:repeat var="newLineItem" value="#{SelectionBean.Cards}" >
<span class="new-line-item">
<h:commandLink id="no-#{newLineItem.serNo}"
styleClass="#{SelectionBean.serNo == newLineItem.serNo ? 'selected' : ''} btn"
action="#{SelectionBean.populateSelectedNum(newLineItem.serNo)}">
<f:ajax render=":form:numberSelectionPanel" execute="@form"/>
#{newLineItem.serNo}
</h:commandLink>
</span>
</ui:repeat>
</h:panelGroup>
some more code
</h:panelgroup>
</h:form>
在SelectionBean方法中
public void populateSelectedNumber(String number) {
this.serNo = number; // I added debug point here
selectedMnpMessage = null;
}