Facelet tag parameter not recognized by PrimeFaces p:ajax

谁说胖子不能爱 提交于 2019-12-04 03:34:50
jFrenetic

My colleague has just provided a patch to resolve this issue.

The current implementation of AjaxBehaviorListenerImpl#processAjaxBehaviour is as follows:

public void processAjaxBehavior(AjaxBehaviorEvent event) throws AbortProcessingException {
        FacesContext context = FacesContext.getCurrentInstance();
        final ELContext elContext = context.getELContext();

        try{
            listener.invoke(elContext, new Object[]{});
        } catch (MethodNotFoundException mnfe) {
            MethodExpression argListener = context.getApplication().getExpressionFactory().
                        createMethodExpression(elContext, listener.getExpressionString(), null, new Class[]{event.getClass()});

            argListener.invoke(elContext, new Object[]{event});
        }
    }

He proposes to tweak it like this:

import javax.faces.view.facelets.FaceletContext;

public void processAjaxBehavior(AjaxBehaviorEvent event) throws AbortProcessingException {
        FacesContext context = FacesContext.getCurrentInstance();
        final ELContext elContext = context.getELContext();

        try{
            listener.invoke(elContext, new Object[]{});
        } catch (MethodNotFoundException mnfe) {
            FaceletContext fc = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
            MethodExpression argListener = context.getApplication().getExpressionFactory().
                        createMethodExpression(fc, listener.getExpressionString(), null, new Class[]{ event.getClass() });

            argListener.invoke(elContext, new Object[]{ event });
        }
    }

Hopefully this will be approved by PF team.

The tweak does not work with my use case which is more complex than a single ui:include.

<c:forEach items="#{items}" var="item">
            <ui:include src="#{item.uri}">
                <ui:param name="itemBean" value="#{item.bean}"/>
            </ui:include>

</c:forEach>

I think the listener's variable mapper must be reused inside the new MethodExpression

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