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

Incorrect use of apex:param tag??
I have a method in my controller that is not being sween by the page, even though the names are identical
I am using a commandLink in a pageblocktable for each line. the action for the link goes to a method that requries a class object for its argument. Whereas each of the lines on the page are made up of these class objects, I apparently have to associate the line object with a property in the controller. So, the line object code is:
public LineQuote generateLQ; public LineQuote getGenerateLQ() { return generateLQ; } public void setGenerateLQ(id lqID) { system.debug('Set LQ LineQuote from apex:param'); generateLQ = null; for (LineQuote GL :Ws_QOALQs) { if (lqID == GL.OppItem.ID) { generateLQ = GL; system.debug('Found CreateLineItem assigned to LQ'); } } }
So the page code for the link in the line is:
<apex:pageBlockTable id="ProductsTable" style="text-align: center" value="{!Ws_QOALQs}" var="LQ" columns="10" align="center" > <apex:column headerValue="Click to Generate RequestID" width="10%"> <apex:CommandLink value="Generate RequestID" action="{!GenerateRequestID}" reRender="theMessages"> <apex:param name="LQ" value="{!LQ.OppItem.ID}" assignTo="{!generateLQ}" /> </apex:CommandLink> </apex:column> </apex:pageBlockTable>
So, the CommandLink calls the GenerateRequestID method in the controller (shown below), and uses the parameter tag to assign the line's Id to the setGenerateLQ method where it is used by the controller in this method:
public PageReference GenerateRequestId(LineQuote LQ) { PageReference returnPage; returnPage = new PageReference(Ws_QOA.QOA_DetailedQuote_Create(LQ)).setRedirect(true); return returnPage; }
So, currently the page doesn't recognize this method. However, if I remove the LineQuote LQ argument, it sees the method, for example
public PageReference GenerateRequestId(){return null;}
So, I don't know if I'm using the param tag incorrectly, or if I'm calling the method incorrectly, or if I even need to send the LQ object to the method at all. I believe I do as an almost exact copy of the process is working for another page on another controller, but I can't identify the significant difference.
Any ideas on why my page recognizes one version of the method, but not the other, and is it the way I'm using the param tag or something else??
There is no way to directly pass an argument to a method (except, arguably, with an actionFunction). That is why you have params in the first place.
I think you want something like this:
And this:
All Answers
There is no way to directly pass an argument to a method (except, arguably, with an actionFunction). That is why you have params in the first place.
I think you want something like this:
And this:
yes. also you can use this method to pass parameter value using apex param tag.
And
-Suresh
Thanks to both responders!!
I used the first method, however as for the second where the following is used.
String lq = ApexPages.currentPage().getParameters().get('LQ');
Does the getParameters() method work to capture the value of any component in the page, as long as it is identified with an id attribute??
String lq = ApexPages.currentPage().getParameters().get('LQ');
>Does the getParameters() method work to capture the value of any component in the page,
No cannot use for every components.apex param has name attribute that's why I used getParameters() method. Also can use with html components(name attribute necessary).
>as long as it is identified with an id attribute?
No it is not identified with id attribute
-Suresh