javaee / mojarra

PLEASE NOTE: This project has moved to Eclipse Foundation and will be archived under the JavaEE GitHub Organization. After Feb. 1, 2021, the new location will be github.com/javaee/mojarra. Mojarra - Oracle's implementation of the JavaServer Faces specification
https://github.com/eclipse-ee4j/mojarra
Other
164 stars 58 forks source link

Composite Component EL resolve fails #2013

Closed javaserverfaces closed 11 years ago

javaserverfaces commented 13 years ago

Consider a DataTable with a DataModel. The DataTable is placed in a composite component called testGrid. The component has a backing class, in which we want to programmatically access the DataModel. This is where we ran into some unexpected behaviour.

For this testcase the DataTable is placed on a page called TestCaseDatatableModelLoading. This page has a backing bean called TestCaseBackingBean.

The page contains the DataTable and a Button. When the button is clicked, we try to access the data in the DataTable. The listing of xhtml is shown below (and can be found in the attached files). The listing of the java classes is limited to the methods which are called.

The button click is handled by the testAction() method in the Backing Bean, which looks up the grid and calls the backing class's method. This method then gets the DataModel and calls getRowData(). In the example the first way of doing this works; but the second does not.

The reason the first works, is that the DataModel is obtained by resolving the expression directly on our composite.

The reason the second does not work is that in the background, the second method also uses an ELExpression to get the DataModel on which getRowData() is called. The difference appears to be that when this "extra layer" of resolving is added (so from "outside" the current composite component), the ELContext is limited to the originator of the execution, in this case the Button. The actual method which fails to return the Composite Component is: com.sun.faces.component.CompositeComponentStackManager.findCompositeComponentUsingLocation(FacesContext ctx, Location location). This method is used to find the composite, to then push it to EL, but since it can't be found it is not pushed to EL and the original (in this case cc.DataModel) resolve fails.

To make it work, the out-commented lines can be added. These will put our component on the EL stack and then it can be found as expected.

The question/problem is as follows: When using a backing class, and calling components from your code, if the method you call uses expression logic on any component outside the composite component except for the one triggering the execution, the expression will fail unless you manually add yourself (or any other components required) to the EL context. What I originally expected was that the context would contain either the full tree or, when using AJAX, the partial tree as submitted. The current behavior is very confusing, as a user I expected to be able to call methods on my components as long as they are within the submitted context...

A project is included which contains all the code mentioned, and demonstrates the problem.

Thanks in advance,

Richard Arnoldussen

Environment

JSF 2.1 on a JBoss AS 6.0 server with as Mojarra implementation 2.1.1

Affected Versions

[2.1.0]

javaserverfaces commented 13 years ago

Reported by rarnoldussen

javaserverfaces commented 13 years ago

rogerk said: triage. Thanks for the attachments.

javaserverfaces commented 13 years ago

kito75 said: Just ran into this issue myself (occurs in MyFaces 2.07 and Mojarra 2.06 as well). Note that you can reproduce it with a any component inside of a composite (doesn't have to be a DataTable). The main problem is that if you reference a property of child component anywhere outside of the composite (i.e. in an action method, a component system event, etc.), it simply will not work if it was set to a composite component attribute (i.e. "#

{cc.attrs.property}

". This is because the EL evaluation code can't find the parent composite component.

javaserverfaces commented 13 years ago

kito75 said: Just filed this issue with MyFaces: https://issues.apache.org/jira/browse/MYFACES-3283.

javaserverfaces commented 11 years ago

@manfredriem said: Can you verify if this is still an issue on the latest 2.1 release?

javaserverfaces commented 11 years ago

@manfredriem said: Lowering priority because of no response

javaserverfaces commented 11 years ago

@manfredriem said: Lowering priority because of no response

javaserverfaces commented 11 years ago

@manfredriem said: Closing because of inactivity

javaserverfaces commented 13 years ago

File: datatablemodelloading.zip Attached By: rarnoldussen

javaserverfaces commented 13 years ago

File: [Testcase Datatable model loading.doc](https://java.net/jira/secure/attachment/45372/Testcase Datatable model loading.doc) Attached By: rarnoldussen

javaserverfaces commented 13 years ago

Issue-Links: is related to JAVASERVERFACES-2839

javaserverfaces commented 7 years ago

This issue was imported from java.net JIRA JAVASERVERFACES-2009

javaserverfaces commented 11 years ago

Marked as incomplete on Wednesday, May 8th 2013, 2:03:41 pm