Use jsFunction component, see there
You can render function call and call it onclick at any link.
That call some action on server and re-render portion on screen.
If you do not need an action, just create an empty one.
If not mistaken, the jsFunction needs to be in a form.
Wouldn't that also pass along the view state?
Can you give an example of how to implement this? I downloaded the demo but the code doesn't reflect my problem.
You are right. It requires the form and keeps the state updated.
What you want names "Non-Faces Request generates Faces Response" in JSF Specification. According to specification, the lifecycle has a shortcut for this case. Just after Restore Phase, the lifecycle create a new view and jumps to Render Response phase and render the whole view.
So, where is no room for Ajax response in this scheme if the standard JSF lifecycle is not modified. Ajax4jsf has a custom lifecycle only for getting the resources.
Not sure what the answer to your reply is... Are you saying there's no way to do what I want to implement with ajax4jsf? Or that I have to modify the lifecycle to get what I need? (which I have no idea where to start)
Basically I just want to have different links each with different query strings that update an div element responsible for being updated with content from the ajax response. The response could contain a form.
My goal is to have one main page for my app. That main page updates itself with the content from other pages. I want to make the app pure ajax.
So what do you recommend I do?
I know I could always modify the dom on the main page to include an iframe and then have every page in the iframe use ajax. I'm trying to avoid that. Seems like a ghetto solution.
Ajax4jsf is "Ajax for JSF". What you are going to accomplish is not about JSF.
Using JSF and following non-JSF approaches is really not anoptimal way to go. So, I recommend do not follow this way.
sounds good. I guess I will just have to change my app then.
May be you just need a form on your main page?
The direction I took was to keep Ajax4jsf FOR JSF.
Even though the Prototype framework is completely different than Ajax4jsf and for different purposes (lemons and apples) - I find that for most of my requirements (this problem and others) that Prototype can wield the same end results. Even when it comes to form submissions and viewstates.
So I'm still using for ajax4jsf for the few certain things (JSF Related), but maybe one day I will find a replacement for that.
Ajax4jsf uses Prototype. However, it is about 0.3% of the whole functionality.
If you replace part of the page using non-JSF request, the new view will be created on the server. As a result, your page will contain representation of several views. JSF architecture does not presume this situation is possible. Some glitches might happen sooner or later.
I can see that happening. I just need to be really careful that it doesn't.