My favorites | Sign in
Project Home Wiki Issues Source
New issue   Search
  Advanced search   Search tips   Subscriptions
Issue 4075: Facelet composition parameter not resolved by p:ajax
31 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Closed:  Oct 2012

Sign in to add a comment
Reported by, May 21, 2012
Parameter passed to ui:composition is not resolved by p:ajax

PrimeFaces version: 3.0, 3.1, 3.3 RC1?

What is the expected output? What do you see instead?
The passed parameter should be resolved normally. Instead I get PropertyNotFoundException

Which JSF implementation with version are you using?
Mojarra (bundled with Glassfish)

What is the version of your JSF implementation?

Which component libraries are you using in addition to PrimeFaces?

Which application server or servlet container are you using?
Glassfish 3.1.2

Test case:

<ui:composition xmlns=""
	<f:view contentType="text/html">
	    <h:form id="content" prependId="false">
	      <ui:include src="/WEB-INF/page2.xhtml">
	        <ui:param name="controller" value="#{testViewBean}" />

<ui:composition xmlns=""
	    <p:inputText id="foo" value="#{}">
		<p:ajax event="blur"
			listener="#{controller.update}" />

public class TestViewBean implements Serializable {
   private String foo;
   public String getFoo() { return foo;	}
   public void setFoo(String foo) { = foo; }
   public void update(AjaxBehaviorEvent e) {
     System.out.println("event handled");

In the example above, the attribute "value" of p:inputText is resolved normally, as expected, but p:ajax throws PropertyNotFoundException when "blur" event happens (see the attached log).

Also, see the similar issue on RichFaces issue tracker, which was eventually resolved: (the only difference is that in my case I pass ValueExpression instead of MethodExpression).

I also asked this question on
3.2 KB   View   Download
May 23, 2012
The patch below will fix this issue.

> import javax.faces.view.facelets.FaceletContext;
>             FaceletContext fc = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
<                         createMethodExpression(elContext, listener.getExpressionString(), null, new Class[]{event.getClass()});
>                         createMethodExpression(fc, listener.getExpressionString(), null, new Class[]{ event.getClass() });

May 23, 2012
sorry, forgot file name: AjaxBehaviorListenerImpl
May 29, 2012
Project Member #3
Does f:ajax work?
May 29, 2012
> Does f:ajax work?
Yes, it does.
Jun 25, 2012
Reproduced on primefaces 3.3.1

The error comes from AjaxBehaviorListenerImpl.processAjaxBehavior which do not reconstruct/reuse correctly the variable mapper of the listener : 

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

If the event listener has no parameter it works because "listener" has the correct variable mapper.

Jul 20, 2012
The listner MethodExpression is build on TagHandler#apply with FacletesContext as ElContext. That's why the listener expression works well. 

The new builded argListener MethodExpression in AjaxBehaviorListenerImpl.processAjaxBehavior doesn't have the FacletesContext anymore and so all Facelets variables like ui:param are lost.

Therefore I think it's needed to build all possible MethodExpressions for the AjaxBehavior in the TagHandler#apply like e.g. MyFaces does it in the f:ajax TagHandler.
Oct 29, 2012
You can find as attachment a patch and the source code modified

The patch modifies AjaxBehaviorListenerImpl :
- I have added a second MethodExpression args (listenerWithArg) to its constructor  
- processAjaxBehavior method first calls the original listener.invoke. If the method is not found it calls listenerWithArg.invoke

The patch modifies AjaxBehaviorHandler :
- createAjaxBehavior constructs AjaxBehaviorListenerImpl with a second MethodHandler which takes a AjaxBehaviorEvent as an argument
4.2 KB   Download
Oct 30, 2012
You gotta be kidding me! I opened this ticket half a year ago. 16 people starred it, some even attached their patches, and it's still in Review phase? I understand, I'm not a premium user, but it's clearly a bug. Way to go, PF team!
Oct 30, 2012
Project Member #10
This is common in open source projects, not only PrimeFaces related. There are priorities. We'll review this in the future, currently the team has no free time on this due to PRO user requests and regular workload of other projects, thanks for your understanding. If this is urgent, please consider PrimeFaces PRO.
Oct 31, 2012
Project Member #11
Set to review for 3.4.2 (release date next week) and 3.5.
Labels: -TargetVersion-FUTURE TargetVersion-3.4.2 TargetVersion-3.5
Oct 31, 2012
Project Member #12
(No comment was entered for this change.)
Status: Accepted
Oct 31, 2012
Project Member #13
Fixed for 3.5 and 3.4.2. 

Anton, I'd appreciate if you can understand the workload of ours, dealing with PrimeFaces PRO user requests to keep the business going, consulting, training and project development work plus on top of these trying to satisfy community users who has thousands of requests. This is common in any popular open source project, not just PrimeFaces. So we have priorities and work according to them. Hope you consider this and be more constructive in your future comments in issue tracker and forum.
Status: Fixed
Labels: -Type-NewFeature Type-Defect
Oct 31, 2012
If I pull the 3.5 snapshot right now will I get this fix?
Oct 31, 2012
Sorry for being rude. I understand your workload and appreciate your efforts. I just thought that people who attached their patches deserved some attention. Because, even if they are not PRO users, they actually spent their time to fix the bug. I'll consider your notes on being more constructive next time.
Nov 8, 2012
this patch solved many of my problem (with input, selectOneRadio...) but do not solve case on a calendar with ajax event dateSelect

to reproduce: pass the ui_prm_bean as an ui param

<p:calendar value="#{}">
<p:ajax event=”dateSelect” listener=”#{ui_prm_bean.handleDateSelect}” update=”msg” />

// as in user guide 3.4
public void handleDateSelect(DateSelectEvent event) {
Date date = event.getDate();
//Add facesmessage

If i change the signature with param event as AjaxBehaviorEvent type, it's better, but event must be then casted to DateSelectEvent to get the date ...


Nov 26, 2012
not resolved in 3.4.2 yet, same issue
Nov 26, 2012
if you use the following method signature in the example above it should work.

public void handleDateSelect(ActionBehaviorEvent event) {
    DateSelectEvent dateSelectEvent = (DateSelectEvent)event);

Using DateSelectEvent directly doesn't work with ui:param.
Dec 6, 2012
Project Member #19
 Issue 4621  has been merged into this issue.
Dec 10, 2012
There remains a problem with this for itemSelect event listeners for p:autocomplete tags in PF 3.4.2.
You need to use the method signature workaround to get it working:

This works:
public void onSelect(AjaxBehaviorEvent event) {
   Object selectedItem = ((SelectEvent) event).getObject();

This fails:
public void onSelect(SelectEvent event) {

javax.el.PropertyNotFoundException: Target Unreachable, identifier 'relationBean' resolved to null

<ui:include src="/relation/form.xhtml">
   <ui:param name="relationBean" value="#{supplierBean}" />

<ui:include src="/relation/form.xhtml">
   <ui:param name="relationBean" value="#{supplierBean}" />

<p:autoComplete ...>
   <p:ajax event="itemSelect" listener="#{relationBean.postalCodeCityCompletion.onSelect}"
Dec 19, 2012
Project Member #21
 Issue 4585  has been merged into this issue.
Jan 24, 2013
It looks that this issue still exists in 3.5.RC
Feb 4, 2013
Still exists in current 3.5.RC1.
Feb 4, 2013
The workaround using AjaxBehaviorEvent instead of the primefaces events and cast in the listener methode works.

Using primefaces event class directly in mehtode signature won't work. IMHO this couldn't be fixed easily because at this stage when the methode expression is built you don't know, which event was fired.

IMO the workaround described above is the only way at the moment.
May 12, 2013
The issue still exist in PF 3.5. I've not tested workarounds with cast of ActionBehaviorEvent, etc., but it's really annoying that we can not pass beans into ui:include via ui:param because they can not be resolved in p:ajax.

For now I use o:methodParam from OmniFaces to rescue the app. It works with o:methodParam when it's placed within included page. 
Sign in to add a comment

Powered by Google Project Hosting