You need to sign in to do that
Don't have an account?
adreamer
query string to commandButton action
Hi there,
I would like to add a query string to the action attribute of a command button. The idea is that I pass in parameters to the controller's method for that action. The Visual Force reference manual say: " To add query string parameters to a commandButton, specify them in the associated action method". My question is: how is the sintax for that ?.
Something like this does not work :
Fernando
I would like to add a query string to the action attribute of a command button. The idea is that I pass in parameters to the controller's method for that action. The Visual Force reference manual say: " To add query string parameters to a commandButton, specify them in the associated action method". My question is: how is the sintax for that ?.
Something like this does not work :
<apex:commandButton action="{!save}?q={!myObject.id}" value="Save" id="theButton"/>Thank you very much in advance.
Fernando
<apex:commandButton action="{!save}" value="Save" id="theButton">
<apex:param name="q" value="{!myObject.id}">
</apex:param>
</apex:commandButton>
Then in your controller, do this --
String q= ApexPages.currentPage().getParameters().get('q');
Message Edited by tonitonitone on 07-31-2008 10:52 AM
It did not work, and it was expected because the Visual Force reference says for the param component that : "The param component can only be a child of an outputLink, outputText, or a actionFunction component".
I have solved the problem in a different way because I realized I was trying to send as a parameter of a query string something that came from the controller in the first place. So I had what I needed in the controller state, and a change in the logic did the trick.
Having said that, I am stil intrigued by the fact that the Visual Force reference says that it is possible to add a query string to the commandButton, it says that it should go in the action attribute, but it does not say what the syntax should be. Is it a trial error thing ? :)
I agree though that this is logic you should leave to your controller.