PrimeFaces p:ajax无法识别Facelet标签参数 [英] Facelet tag parameter not recognized by PrimeFaces p:ajax

查看:132
本文介绍了PrimeFaces p:ajax无法识别Facelet标签参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的Facelet标签:

I have a simple Facelet tag:

<ui:composition>
  <ui:insert />
</ui:composition>

,用于避免声明多个c:set标签.
假设我以名称view在facelets taglib库中注册了它,并像这样使用它:

which is used in order to avoid declaring multiple c:set tags.
Let's say I registered it in the facelets taglib library with the name view, and use it like this:

<my:view bean="#{myController}">
  <p:inputText value="#{bean.value}>
    <p:ajax event="blur" process="@this" listener="#{bean.handleValueChanged}" />
  </p:inputText>
</my:view>

属性valuep:inputText完全解析,但是p:ajax抛出此错误:

The attribute value is perfectly resolved by p:inputText, but p:ajax throws this:

Target Unreachable, identifier 'bean' resolved to null
javax.el.PropertyNotFoundException: Target Unreachable, identifier 'bean' resolved to null
    at com.sun.el.parser.AstValue.getTarget(AstValue.java:153)
    at com.sun.el.parser.AstValue.invoke(AstValue.java:237)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:302)
    at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39)
    at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
    at org.primefaces.component.behavior.ajax.AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxBehaviorListenerImpl.java:47)

是错误还是预期的行为?

Is it a bug or expected behavior?

更新: 我只是用f:ajax尝试了同样的方法,它起作用了!

Update: I just tried the same with f:ajax and it worked!

顺便说一句,环境如下:
Glassfish 3.1.2
PF 3.0、3.2、3.3

Btw, the environment is as follows:
Glassfish 3.1.2
PF 3.0, 3.2, 3.3

Update2 :
RichFaces相同的问题是完全相同的.似乎就像是PrimeFaces错误(我今天将在PF错误跟踪器上发布一个问题).

Update2:
This issue with RichFaces is absolutely identical. Seems to be like a PrimeFaces bug (I'll post an issue on PF bug tracker today).

推荐答案

我的同事刚刚提供了一个补丁来解决此问题.

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

AjaxBehaviorListenerImpl#processAjaxBehaviour的当前实现如下:

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});
        }
    }

他建议像这样调整它:

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 });
        }
    }

希望这会得到PF小组的批准.

Hopefully this will be approved by PF team.

这篇关于PrimeFaces p:ajax无法识别Facelet标签参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆