gpt4 book ai didi

ajax - h :commandLink actionlistener is not invoked when used with f:ajax and ui:repeat

转载 作者:行者123 更新时间:2023-12-04 20:12:32 26 4
gpt4 key购买 nike

h:commandLink actionlistener 在与 f:ajax 和 ui:repeat 一起使用时不会被调用当我单击链接时,我必须在 bean 的“onload”方法中传递一个参数并刷新面板组“assist”。当我使用 commandButton 但不使用 commandLink 时它工作正常。

<h:panelGroup id="assist" styleClass="tabbed-panel-vertical">
<ul id="assistlink" class="tabbed-panel-vertical-tabs">
<ui:repeat var="assistants"
value="#{permissions.repAssistants}">
<li><h:commandLink
actionListener="#{permissions.onload}"
value="#{assistants.name}"
styleClass="#{permissions.selectedAssistant==assistants.userId ? 'selected' : ''}">
<f:ajax
render=":permissionsform:assist :permissionsform:permissionsContent"
execute="@this">
<f:attribute name="assistantId"
value="#{assistants.userId}" />
</f:ajax>
</h:commandLink></li>
</ui:repeat>
</ul>

    `public void onload(ActionEvent event) {
Long userId = Long.valueOf(541);// user.getUserId();
Long assistantId = (Long) event.getComponent().getAttributes().get("assistantId");
System.out.println("User " + assistantId);
}`

最佳答案

根据评论:

@BalusC Its javascript issue. Thanks for directing me to look at the javascript console. JS error "Uncaught ReferenceError: mojarra is not defined"

确保您有一个 <h:head>在您的主模板中标记而不是 <head> .这样,JSF 将能够自动包含 Ajax 魔法所需的 JavaScript 文件。

关于ajax - h :commandLink actionlistener is not invoked when used with f:ajax and ui:repeat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9933777/

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