H:commandLink的ActionListener不调用使用f当用于Ajax和UI:重复 [英] h:commandLink actionlistener is not invoked when used with f:ajax and ui:repeat
问题描述
H:commandLink的ActionListener不调用使用f当用于Ajax和UI:重复 当我点击链接,我必须通过在bean的的onload方法的参数并刷新panelGroup中协助。它工作正常,当我使用命令按钮,但不与commandLink。
< H:panelGroup中的id =协助的styleClass =标签面板垂直>
< UL ID =assistlink类=标签面板,垂直标签>
< UI:重复VAR =助手
值=#{permissions.repAssistants}>
<李>< H:commandLink
的ActionListener =#{permissions.onload}
值=#{assistants.name}
的styleClass =#{?permissions.selectedAssistant == assistants.userId'选择':''}>
< F:AJAX
渲染=:permissionsform:帮助:permissionsform:permissionsContent
执行=@这个>
< F:属性名=assistantId
值=#{assistants.userId}/>
< / F:AJAX>
< / H:commandLink>< /李>
< / UI:重复>
< / UL>
`公共无效的onload(ActionEvent的事件){
龙用户id = Long.valueOf(541); // user.getUserId();
龙assistantId =(长)event.getComponent()的getAttributes()获得(assistantId)。
的System.out.println(用户+ assistantId);
}`
根据的评论:
@BalusC它的JavaScript的问题。谢谢指导我看JavaScript控制台。 JS错误未捕获的ReferenceError:mojarra没有定义的
请确保你一个< H:头>
在你的主模板,而不是标签< HEAD>
。这样,JSF将能够自动包括对Ajax的魔力必要的JavaScript文件。
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);
}`
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.
这篇关于H:commandLink的ActionListener不调用使用f当用于Ajax和UI:重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!