Disclaimer : This is an homework exercise. Sort of. I'm trying to learn Visualforce + APEX + web design in a very short term, so I'm asking my friends to put up challenging questions for me.
My aim : show an alert/message when the user presses a button. Using ActionFunction. I must use Action Function
Problems I am facing :
- Please look at my code VF page. I have marked the problem with a comment.
- I donot know enough about AJAX/JS to fulfill all requirements.
- The code is behaving weird.
- I can display the alert/message without Action Function, I dont know how WITH AF.
- The page refreshes after I click the button. Does a command button ALWAYS refresh after you click it?
I will expand on problem 1 :
If I remove the offending line, the code does not work. I click the button and page refreshes. NOTHING happens.
If I keep the offending line, when I click the button, it displays a JS alert and a few seconds later, it displays the Salesforce type error/message. WHY??
Is it possible to call a JS function from the controller?
My logic is like this :
- Click the button.
- It calls a JS function
- the JS function calls the function related to the Action Function, and THAT in turn calls the controller function associated with the AF.
- the controller calls back/returns value/changes a getter/setter to some value.
- the value is taken by some other JS function defined in the page and it triggers a condition check (I'm pulling words out of my @$$ here) and THAT displays and alert.
I hope this is not asking for the impossible??
I donot ask you folks to provide me a full detailed answer, just a few nudges in the right direction would be enough!! I dont need much hand holding.
Sorry for the wall of text.