Loading ajax load in JSF

Ok, here's my problem: I have a JSF application and some JSP files. Let's say I have a main.jsp that has a view and includes a sub.jsp. This works great. sub.jsp contains a sub clause. As a result, all IDs of form elements in sub.jsp follow the form "subview: component". Now let's say I am using some ajax and want to get a sub.jsp jsp page and include it in a DIV somewhere. All IDs are now in the form "component". I have no idea how to do this and checking for two different sets of ids in my interactive javascript is a pain. Is there a way to get consistent IDs?

I tried: Removing the subheading - (then the AJAX call will fail because no view is found)

and

h: form prependid = false - this only removes the form id, not the id of the sub

+1


source to share


2 answers


AJAX is tricky with JSF. If the JSF framework you are using does not support it, you will run into many view state issues.

I'm surprised that no exception is thrown when you access sub.jsp directly - there should be no h: view in sub.jsp and no UIViewRoot, I'm not sure how the UI tree will be created. If you have h: view in sub.jsp then you are putting two UIViewRoots in your UI tree - this is a bug. (The JSF component tree is roughly similar to that of other Java widget sets, such as Swing or SWT.)



I suspect the problem you are seeing is that you are sending a different view to the one that was originally provided. Since the component tree is completely different, clientIds will be generated from a different view root. You can read about how they are built in this answer .

In short, I don't think the mechanism you are using to update the client is valid.

+2


source


Have you looked at ajax4Jsf (aka Richfaces)?



0


source







All Articles