Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Apex Code Development
- :
- get input text value from pageblocktable
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
get input text value from pageblockt able
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-14-2012 02:32 PM
Hi,
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:commandLink>
</apex:column>
</apex:column>
<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>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
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('quote Id');
}
public Integer getQuantity()
{
return quantity;
}
public void setQuantity(Integer newTD)
{
quantity=newTD;
}
public List<Product2> getProductsList()
{
try{
String query = 'SELECT ID, NAME, Available_quantity__c, Total_Quantity__c, Size_Dimensions__c FROM Product2 ';
productsList = Database.query(query);
}
catch(Exception e)
{
System.debug(e.getMessage());
}
return productsList;
}
public PageReference selectId(){
productId = System.currentPageReference().getParameters().get( 'prodid');
Quote__c quote = [Select id,Name from Quote__c where id=:quoteId];
if(productId.length()>15){
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.
Re: get input text value from pageblockt able
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-14-2012 03:06 PM
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?
Application Architect
Check out the developer documentation | Got an idea? | Vote for this Idea!
Re: get input text value from pageblockt able
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-14-2012 03:39 PM
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.
Re: get input text value from pageblockt able
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-18-2012 12:20 AM
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.
Certified Salesforce Technical Architect, Developer, Advanced Developer, Administrator, Advanced Administrator, Consultant, Sales Cloud Consultant,Service Cloud Consultant
Force.com MVP | The Bob Buzzard Blog | Linked In | Twitter
I don't respond to private messages/emails asking for help.
Take the Bob Buzzard Sobject Fields quiz.

