You need to sign in to do that
Don't have an account?
raseshtcs
Passing parameter from input text inside a pageblock table to a controller method
I have a page block table with a number of columns, The first is an input text where the user would enter id of a record, in the next two columns i want to fetch record information of the id entered by the user. I am trying to do this on blur using action support. below is the code
PAGE
<apex:pageBlockTable id="bodyTable" value="{!Records}" var="acc" rowClasses="odd,even" styleClass="tableClass" cellpadding="" cellspacing="" align="center"> <apex:column style="text-align:center;"> <apex:facet name="header">Number</apex:facet> <apex:outputPanel > <apex:inputText value="{!acc.no}"> <apex:actionSupport event="onblur" action="{!getInfo}" reRender="bodyTable" status="counterStatus"> <apex:param name="seno" value="{!acc.no}"/> </apex:actionSupport> </apex:inputText> </apex:outputPanel> <apex:actionStatus id="counterStatus" startText="Fetching.." stopText=""/> </apex:column>
then there are rest of the colums
In the Class if I am trying to acces what the user entered in the text box, it gives me null
public PageReference getInfo(){ String sNumber = ApexPages.currentPage().getParameters().get('no'); system.debug('GET INFO CALLED'+sNumber); return null; }
Any clues where i might be wrong
As the onblur method is nested in the input field, can you not use the 'this' syntax?
All Answers
The problem here is that the apex parameter value is determined at render time as you have used a merge field. Thus if this values starts out empty, that is what will be sent through to the controller.
The way I'd approach this is to create an actionfunction that takes a parameter, then invoke that from the onblur javascript with the value from the HTML element.
Thanks for your quick reply. I am not sure if would be able to use the HMTL id to get the parameter value, as the table is a dynamic one with the user having an option to go on adding rows as he wants, I checked the ids generated for the input text, they are as follows
j_id0:form:pageblock:pbsection:bodyTable:0:input
j_id0:form:pageblock:pbsection:bodyTable:1:input
j_id0:form:pageblock:pbsection:bodyTable:2:input
So my problem is how would my code understand from which id to pick after the on blur method
As the onblur method is nested in the input field, can you not use the 'this' syntax?
Worked well... Thanks