我正在写一个JSF页面,然而,一个命令按钮在页面加载时多次调用它的操作,但没有人点击它……这打乱了我的整个进度。。。
HTML:
<h:panelGrid columns="2" cellpadding="10">
<h:form>
<table>
<tr>
<td>姓名:</td>
<td><p:inplace editor="true"><p:inputText value="#{user.name}"/></p:inplace></td>
</tr>
<tr>
<td>联系方式:</td>
<td><p:inplace editor="true"><p:inputText value="#{user.phone}"/></p:inplace></td>
</tr>
<tr>
<td>性别:</td>
<td><h:outputText value="#{user.gender}"/></td>
</tr>
<tr>
<td>身份证号:</td>
<td><p:inplace editor="true"><p:inputText value="#{user.pid}"/></p:inplace></td>
</tr>
<tr>
<td style="position:absolute; right:30px;"><p:commandButton value="删除" action="#{info.removeUser()}"/></td>
</tr>
</table>
</h:form>
java:
public void removeUser(){
System.out.println("Current tab:"+index +" Removed............");
users.remove(Integer.parseInt(index));
}
这里的"index"是accordionPanel中的当前选项卡,它是一个字符串。。。
没时间在这里提问,也许我遗漏了一些信息。。。
如果您忘记在视图中声明p
XML名称页,就会发生这种情况。
xmlns:p="http://primefaces.org/ui"
如果忘记声明p
XML名称空间,那么所有p:xxx
标记都将被视为纯文本。属性中的所有EL表达式都会立即执行,就好像它们嵌入在纯文本中一样。这也包括#{info.removeUser()}
表达式。"多次"很可能与视图中出现的EL表达式的数量相同。