gpt4 book ai didi

jsf - JSF 中未调用操作方法

转载 作者:行者123 更新时间:2023-12-02 12:19:25 25 4
gpt4 key购买 nike

这是我的阶段监听器

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 打印的所有消息阶段。

如果我的 View 没有改变,它会在 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">&nbsp;&nbsp;&nbsp;
<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> &#160;

</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 answer :

Whenever an UICommand component fails to invoke the associated action, verify the following:

  1. UICommand components must be placed inside an UIForm component (e.g. h:form).
  2. You cannot nest multiple UIForm components in each other (watch out with include files!).
  3. No validation/conversion error should have been occurred (use h:messages to get them all).
  4. If UICommand components are placed inside an UIData component, ensure that exactly the same DataModel (the object behind the UIData's value attribute) is preserved.
  5. The rendered and disabled attributes of the component and all of the parent components should not evaluate to false during apply request values phase.
  6. Be sure that no PhaseListener or any EventListener in the request-response chain has changed the JSF lifecycle to skip the invoke action phase.
  7. Be sure that no Filter or Servlet in the same request-response chain has blocked the request fo the FacesServlet somehow.

另一个原因可能是您没有运行您认为正在运行的代码。

关于jsf - JSF 中未调用操作方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3043789/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com