Issue Details (XML | Word | Printable)

Key: FACESTESTER-13
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: jasondlee
Reporter: IngoHofmann
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
facestester

FacesPage.getFormById() should also find forms that are on a template page

Created: 28/Jul/09 02:37 PM   Updated: 10/Aug/09 09:06 AM
Component/s: FacesTester
Affects Version/s: 0.3, 0.2, 0.1
Fix Version/s: None

Time Tracking:
Not Specified

Tags: getFormById assertionerror


 Description  « Hide

Following this discussion:
http://kenai.com/projects/facestester/forums/forum/topics/1283-getFormById-can-only-find-forms-that-are-on-the-current-page?

Example:
page.xhtml contains some input fields (but no form) and uses template.xhtml as template file that contains the form with id "testForm".

In my test class I figured out the following:

Works fine and returns the HtmlForm:
facesPage.getComponentWithId("testForm").getWrappedComponent();

Does not work and brings up a AssertionError("HtmlForm 'testForm' does not exist on page."):
facesPage.getFormById("testForm");

I guess, for me it would be better when getFormById() would use the getComponentWithId() method rather than parsing the page's component tree.



IngoHofmann added a comment - 03/Aug/09 12:55 PM

Hi, I found the cause of this issue. It is a bug in getFormById().
The problem is not the template (in a simple application it worked fine with an outer form, hence my summary is wrong), but the nesting of the components.

If we look at getFormById():

for (UIComponent each : component.getChildren()) { ... }

you can see that this will iterate only over the first level. If, like in our case, the form is nested with other components (e.g. using nested templates), it can not be found.

Just surround the <h:form> with <ui:component> to get the form one level deeper in the component tree.

Using getComponentWithId(id).getWrappedComponent(); instead the for loop should resolve it.


IngoHofmann added a comment - 10/Aug/09 09:06 AM

Hi Jason,
do you understand the problem? Which drawbacks would have the solution with getComponentWithId(id)?
Cheers,
Ingo