My favorites | Sign in
Project Home Wiki Issues Source
New issue   Search
for
  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
Owner:  cagatay....@gmail.com
Closed:  Oct 2012


Sign in to add a comment
 
Reported by anton.sh...@gmail.com, 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?
2.1.6

Which component libraries are you using in addition to PrimeFaces?
none

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

Test case:

page1.xhtml:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">
	
	<f:view contentType="text/html">
	    <h:head><title>Test</title></h:head>
	    <h:body>
	    <h:form id="content" prependId="false">
	      <ui:include src="/WEB-INF/page2.xhtml">
	        <ui:param name="controller" value="#{testViewBean}" />
	      </ui:include>				
	    </h:form>
	    </h:body>
	</f:view>
</ui:composition>

page2.xhtml:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
	    <p:inputText id="foo" value="#{controller.foo}">
		<p:ajax event="blur"
			listener="#{controller.update}" />
	    </p:inputText>
</ui:composition>

@Named
@SessionScoped
public class TestViewBean implements Serializable {
   private String foo;
   public String getFoo() { return foo;	}
   public void setFoo(String foo) { this.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: https://issues.jboss.org/browse/RF-10781 (the only difference is that in my case I pass ValueExpression instead of MethodExpression).

I also asked this question on stackoverflow.com: http://stackoverflow.com/questions/10691636/facelet-tag-parameter-not-recognized-by-primefaces-pajax
error.log
3.2 KB   View   Download
May 23, 2012
#1 dennis.t...@gmail.com
The patch below will fix this issue.

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

May 23, 2012
#2 dennis.t...@gmail.com
sorry, forgot file name: AjaxBehaviorListenerImpl
May 29, 2012
Project Member #3 cagatay....@gmail.com
Does f:ajax work?
May 29, 2012
#4 anton.sh...@gmail.com
> Does f:ajax work?
Yes, it does.
Jun 25, 2012
#6 nithril@gmail.com
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
#7 buettner...@gmail.com
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
#8 nithril@gmail.com
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



4075.zip
4.2 KB   Download
Oct 30, 2012
#9 anton.sh...@gmail.com
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 cagatay....@gmail.com
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.
Owner: cagatay....@gmail.com
Oct 31, 2012
Project Member #11 cagatay....@gmail.com
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 cagatay....@gmail.com
(No comment was entered for this change.)
Status: Accepted
Oct 31, 2012
Project Member #13 cagatay....@gmail.com
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
#14 chrisb....@gmail.com
If I pull the 3.5 snapshot right now will I get this fix?
Oct 31, 2012
#15 anton.sh...@gmail.com
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
#16 alain.du...@gmail.com
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="#{calendarBean.date}">
<p:ajax event=”dateSelect” listener=”#{ui_prm_bean.handleDateSelect}” update=”msg” />
</p:calendar>

// 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 ...

Thanks

Nov 26, 2012
#17 i.chu...@gmail.com
not resolved in 3.4.2 yet, same issue
Nov 26, 2012
#18 buettner...@gmail.com
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 cagatay....@gmail.com
 Issue 4621  has been merged into this issue.
Dec 10, 2012
#20 jurgen.h...@gmail.com
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

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

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

/relation/form.xhtml
<p:autoComplete ...>
   <p:ajax event="itemSelect" listener="#{relationBean.postalCodeCityCompletion.onSelect}"
Dec 19, 2012
Project Member #21 cagatay....@gmail.com
 Issue 4585  has been merged into this issue.
Jan 24, 2013
#22 sheng...@gmail.com
It looks that this issue still exists in 3.5.RC
Feb 4, 2013
#23 timmy.zi...@gmail.com
Still exists in current 3.5.RC1.
Feb 4, 2013
#24 buettner...@gmail.com
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
#25 ovarak...@googlemail.com
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