h:commandLink actionlistener is not invoked when u

2020-03-26 05:20发布

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条回答
对你真心纯属浪费
2楼-- · 2020-03-26 05:31

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.

查看更多
登录 后发表回答