You need to sign in to do that
Don't have an account?

apex:component + Ajax + Submit.
Just a curious question - I had asked it before but did not get right answer.
1. I have defined a component with one text field / input field.
2. I have a submit button at the bottom of the outputPanel.
3. When I press submit button the value from text box is passed on to the Class object with corresponding getter being called.
4. When I introduce a new button and call some AJAX based function the object is never set.
What is the thing that I am missing?
Is it that component will call the corresponding setter only after submit is called (POST).
- Samarthya
How are you making the ajax call? Are you using an actionFunction? If so, the form should be submitted back in the same way as when clicking a command button.
Yes I am using action button Ajax call runs fine I populated some string with the results of the call and when I push that information to screen it shows. The only problem I have is the component based object setter is not getting called with the values in the text fields for the object variable defined.
Action function I meant. I call a javascript and from java script I make a call to the action function. It runs fine.
Is your actionfunction rerendering a section of the page? There's been a problem around for a while now when submitting values back via apex:param tags and with actionfunctions that don't rerender. I'm wondering if you are experiencing something similar.
No th re-rendering is working fine. May be I am not able to explain it properly. Let me try again (BTW thank you for your kind patience)
1. I am using this to make an AJAX call
This call does not calls the setter for the object for which a component has been defined.
End result I make the AJAX call with dummy parameters perfectly, but the object which I intend to fill in with values from the component (on the same page) fails as there is no submit.
So my question is - Is there a way around it? or I am doing something wrong.
I use the above component on the same page to get the values in the objFill.
- Samarthya
It doesn't sound like you are doing anything wrong, I've used actionfunctions to submit changes via onclick events in the past without issue. Its difficult to understand exactly what you are doing from snippets - is it possible to post your code, or is there too much of it?
The controller code for the page is
I call callWSAJAX() from the action function on the outputPanel click.
The component is
The Address class is simply
and the test page is
If I re-render the complete form will the values be pushed into the component (object)?
I am just speculating (as I did not read it in any documentation) that without actually submitting the data (HTTP POST) the component based object will not receive the values (Setter wont be called).
When I actually replace it with a command LINK or Button - the component recieves the value, but then there is no point in calling AJAX.
- Samarthya
An actionfunction will cause an HTTP post to happen for the form. Then if you re-render the component, it should pick up the latest values.