问题描述
这是我的相位监听器
public class AdminPhaseListener implements PhaseListener {
private static final long serialVersionUID = -1161541721597667238L;
public void afterPhase(PhaseEvent e) {
System.out.println("after Phase " + e.getPhaseId());
}
public void beforePhase(PhaseEvent e) {
System.out.println("before Phase " + e.getPhaseId());
if(e.getPhaseId()== PhaseId.RESTORE_VIEW)
{
}
}
public PhaseId getPhaseId() {
return PhaseId.ANY_PHASE;
}
}
在我的页面中单击命令按钮时,我调用一个动作方法并进行一些处理,但是根本没有调用该动作方法,但是在服务器日志中,我可以看到PhaseListener为所有对象打印的消息.阶段.
如果我的视图未更改,它将在RESTORE_VIEW阶段结束后停止吗?
有什么想法吗?添加有关如何显示命令按钮的代码:
<table width="100%">
<h:column rendered="#{adminBean.displayResultsSize > 0}">
<tr>
<td colspan="14" height="5" nowrap="nowrap" class="WhiteRow"></td>
</tr>
<tr>
<td colspan="14" height="1" nowrap="nowrap" align="center"
bgcolor="#999999"></td>
</tr>
<h:inputHidden id="removeUserId" value="#{adminBean.removeUserId}"/>
<h:inputHidden id="removeIBD" value="#{adminBean.removeIBD}"/>
<h:inputHidden id="removeAPA" value="#{adminBean.removeAPA}"/>
<tr>
<td colspan="14" height="30" nowrap="nowrap"
class="FilterColumnGrayHeader" align="center">
<input type="button" disabled="disabled" id="button_edit"
value="Edit Details" class="disabledfield"
onclick="populateEditRow();">
</input> <h:commandButton type="submit" class="disabledfield" immediate="true"
id="button_remove" value="Remove" onclick="populateRemoveRow();" action="#{adminBean.remove}">
</h:commandButton>  
</td>
</tr>
<tr bgcolor="#000000">
<td colspan="14" height="1" nowrap="nowrap" align="center"
bgcolor="#999999"></td>
</tr>
<tr>
<td height="10"></td>
</tr>
</h:column>
</table>
我引用的是:
另一个原因可能是您没有运行您认为正在运行的代码.
This is my Phase Listener
public class AdminPhaseListener implements PhaseListener {
private static final long serialVersionUID = -1161541721597667238L;
public void afterPhase(PhaseEvent e) {
System.out.println("after Phase " + e.getPhaseId());
}
public void beforePhase(PhaseEvent e) {
System.out.println("before Phase " + e.getPhaseId());
if(e.getPhaseId()== PhaseId.RESTORE_VIEW)
{
}
}
public PhaseId getPhaseId() {
return PhaseId.ANY_PHASE;
}
}
On click of a Command Button in my page, i call an action method and do some processing but the action method is not called at all, but in the server log , i could see the messages printed by my PhaseListener for all the Phases.
If my view was not changed, It would have stopped after the RESTORE_VIEW Phase right?
any thoughts?
Adding the code for How I display the Command Button :
<table width="100%">
<h:column rendered="#{adminBean.displayResultsSize > 0}">
<tr>
<td colspan="14" height="5" nowrap="nowrap" class="WhiteRow"></td>
</tr>
<tr>
<td colspan="14" height="1" nowrap="nowrap" align="center"
bgcolor="#999999"></td>
</tr>
<h:inputHidden id="removeUserId" value="#{adminBean.removeUserId}"/>
<h:inputHidden id="removeIBD" value="#{adminBean.removeIBD}"/>
<h:inputHidden id="removeAPA" value="#{adminBean.removeAPA}"/>
<tr>
<td colspan="14" height="30" nowrap="nowrap"
class="FilterColumnGrayHeader" align="center">
<input type="button" disabled="disabled" id="button_edit"
value="Edit Details" class="disabledfield"
onclick="populateEditRow();">
</input> <h:commandButton type="submit" class="disabledfield" immediate="true"
id="button_remove" value="Remove" onclick="populateRemoveRow();" action="#{adminBean.remove}">
</h:commandButton>  
</td>
</tr>
<tr bgcolor="#000000">
<td colspan="14" height="1" nowrap="nowrap" align="center"
bgcolor="#999999"></td>
</tr>
<tr>
<td height="10"></td>
</tr>
</h:column>
</table>
I'm citing from this answer:
Another cause can be that you're not running the code you think you're running.
这篇关于JSF中未调用action方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!