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

倾然丶 夕夏残阳落幕 提交于 2019-12-01 07:21:54

问题


h:commandLink actionlistener is not invoked when used with f:ajax and ui:repeat When I click the link, I have to pass a parameter in the bean's "onload" method and refresh the panelgroup "assist". It works fine when I use the commandButton but not with 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); 
    }`

回答1:


As per the comments:

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

Make sure that you've a <h:head> tag in your master template instead of <head>. This way JSF will be able to auto-include the necessary JavaScript file for the Ajax magic.



来源:https://stackoverflow.com/questions/9933777/hcommandlink-actionlistener-is-not-invoked-when-used-with-fajax-and-uirepeat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!