+ Start a Discussion

get input text value from pageblocktable



I would want to get the quantity from the input text of the table. I need it so that I can update the quantity for quote_line_items object.


<apex:page standardController="Product2" extensions="ProductListController">
<apex:form >
    <apex:pageBlock title="Products List">
        <apex:pageBlockSection title="List of Available Address" columns="1">
            <apex:pageBlockTable value="{!productsList}" var="prod"> 
                <apex:column headerValue="Select"> 
	    	 		<apex:commandLink value="Select" onclick="return confirm('Are you sure?')" action="{!selectId}" >
		          		<apex:param name="prodid" value="{!prod.id}" />
                <apex:column headerValue="Product Name" >{!prod.Name}</apex:column>
                <apex:column headerValue="Size/Dimensions" >{!prod.Size_Dimensions__c}</apex:column>
                <apex:column headerValue="Total Quantity" >{!prod.Total_Quantity__c}</apex:column>
                <apex:column headerValue="Available Quantity" >{!prod.Available_quantity__c}</apex:column>
                <apex:column headerValue="Quantity Required" >
                    <apex:inputText value="{!quantity}"></apex:inputText>


public with sharing class ProductListController{
    public Product2 product;
    public List<Product2> productsList = null;
    public id quoteId {get; set;}
    public String productId {get; set;}
    public Integer quantity;
    public ProductListController(ApexPages.StandardController controller)
        product = (Product2) controller.getRecord();
        quoteId = ApexPages.currentPage().getParameters().get('quoteId');
    public Integer getQuantity()
	  return quantity;
	public void setQuantity(Integer newTD)
    public List<Product2> getProductsList()
            String query = 'SELECT ID, NAME, Available_quantity__c, Total_Quantity__c,  Size_Dimensions__c FROM Product2 ';
            productsList = Database.query(query);
        catch(Exception e)
        return productsList;
    public PageReference selectId(){
    	productId = System.currentPageReference().getParameters().get('prodid');
    	Quote__c quote = [Select id,Name from Quote__c where id=:quoteId];
			productId = (productId).substring(0,15);	
    	Quote_Line_Item__c quoteLineItem = new Quote_Line_Item__c();    	
    	Product2 product = [Select id, Name from product2 where id=:productId];
    	quoteLineItem.Name = 'PROD - '+quote.Name+'  '+product.Name;
    	quoteLineItem.Product__c =  product.Id;
    	System.debug('*********Quantity*********' + quantity);
    	quoteLineItem.Quantity__c = quantity; 
    	quoteLineItem.Quote__c = quoteId;  	
    	insert quoteLineItem;
    	return new PageReference('/' + quoteId);

 But the quantity value does not pass into the variable. Can you please help me out.



Ron HessRon Hess

you have multiplte rows on your page table, but only one quantity field, so it may be that your controller is bound to multiple fields on that page, which one you get back from the page would be random i think.


if you try it with exactly one row in productsList , does it work as you expect?


It is a list with a quantity text for every row in the list. I have not tried to do it for just one record.


The thing is, you don't have quantity text for every row in the list.  While you have an apex:inputtext element for every row in the list, they are all bound to a single controller property.  This means that every input writes to the same controller property, so the last row to fire a setter wins.


I've explained this in more detail at:




This is referring to a selectlist, but the principle applies to your situation too.

Hi Bob,

I am having code like this:

<apex:repeat value="{!listOfCodes}" var="code">
      <apex:inputTextArea value="{!comment}"/>
    <apex:commandLink action="{!submit}" />

On clicking the submit button,  comment is getting as empty in the controller, even if i enter some text.

Could you please help me with this?.
siddarth rajsiddarth raj
Hi Sure@Dream

Could you please share here your solutions I am got into similar situation spent 2 days on figuring out what and why not returning latest values.....Your reply would really help me. Thanks
raz rraz r
Hi All,
Please provide the solution for the above issue ASAP...

Appriciate your quick response!!!