You need to sign in to do that
Don't have an account?
How to format a value based on locale in <apex : OutputText>
I have a vf page where I am displaying values from a List build from an wrapper class.
Since all of the values are coming from the wrapper class so I am not able to use soObject feilds and I am displaying the output using <apex : OutputText>
e.g. qty - 1000000.0 needs to be displayed as 1,000,000.00
<apex:PageBlockTable value="{!AvailableInventory}" var="AI" width="100%" > <apex:column headerValue="Warehouse"> <apex:outputText value="{!AI.WarehouseName }"/> </apex:column> <apex:column headerValue="Reserved "> <apex:outputText value="{!AI.ReservedQty }"/> </apex:column> <apex:PageBlockTable >
controller code -
public List<cProduct> AvailableInventory = new List<cProduct>{}; public List<cProduct> getAvailableInventoryChild() { return AvailableInventoryChild; } public class cProduct { public id prodInvId {get; set;} public String prodInvName {get; set;} public String OppProdName {get; set;} public String WarehouseName {get; set;} public Double ReservedQty {get; set;} public String color {get; set;} public cProduct( id PIId, String prodInv, String OppProd, String Warehouse, Double Reserved, String InvColor) { prodInvId = PIId; prodInvName = prodInv; OppProdName = OppProd; ProductReference = ProdId; WarehouseName = Warehouse; ReservedQty = Reserved; color = InvColor; } } public List<cProduct> product { get { if(product==null) product=new List<cProduct>(); return product; } set; }
thanks
Thanks TehNrd,
I am trying to create a inventory inquiry page for opportunity. With this approach I can still see another issue, If the user does not have Create Permission on Opportunity then
ShortageQty = new OpportunityLineItem();
will not work.
I have created another sObject and will have full permission for all profiles on this object and I am using this object to hold ShortageQty .
All Answers
Hey
I'm not sure but I think these two article may help:
http://developinthecloud.wordpress.com/2009/06/10/dynamic-custom-labels/
http://developinthecloud.wordpress.com/2009/07/24/dynamic-custom-labels-part-2/
If they don't then you may need to write some code to do the formatting.
Cheers,
Wes
"Since all of the values are coming from the wrapper class so I am not able to use soObject feilds"
Not true my friend! (oh jeez, I sound like McCain, he always says "my friend" ) . You can use sObjects in wrapper classes and then you can use any field on these objects. This especially helps with formatting numbers, dates, currency, etc.
Check out this article I wrote here:
http://wiki.developerforce.com/index.php/Wrapper_Class
Thanks Tehnrd,
What about the calculated values which are not on any sObjects. These columns are calculated on the fly and we want to display their values based on the user's locale.
How do we format them in wrapper class.
global List<cProductInventorys> getretProdInventory() { // get Quantity from OpportunityLineItem requiredQty = [Select Quantity, OpportunityId, pricebookentryId from OpportunityLineItem where OpportunityId = :oppId and pricebookentryId = :pbeId].Quantity ; // clear wrapper class contents retProdInventory.clear(); Map<String, ProductInventory__c> ProdInvLinesMap = new Map<String, ProductInventory__c>(); for ( ProductInventory__c p : [select name, product__c, WareHouse__c, product__r.name, id , AvailableQty__c, InventoryReserve__c, InventoryReserve__r.Sequence__c from ProductInventory__c where product__c = :id order by InventoryReserve__r.Sequence__c ] ) { ProdInvLinesMap.put(String.valueOf(p.InventoryReserve__r.Sequence__c), p); } List<String> ProdInvLines = new List<String>(); for (String ps : ProdInvLinesMap.keySet()) { ProdInvLines.add(ps); } ProdInvLines.sort(); for (String ps : ProdInvLines) { ProductInventory__c ps1 = ProdInvLinesMap.get(ps); retProdInventory.add(new cProductInventorys(ps1)); } return retProdInventory ; } global class cProductInventorys{ global String Line {get; set;} global Double ShortageQty {get; set;} global List<ProductInventory__c> PIList{get; set;} cProductInventorys(ProductInventory__c p, Double requiredQty){ Id PLid = ApexPages.currentPage().getParameters().get('id'); Line = String.valueOf(p.InventoryReserve__r.Sequence__c); PIList=[select id,name, InventoryReserve__c, InventoryReserve__r.Sequence__c , WareHouse__c, AvailableQty__c where InventoryReserve__r.Sequence__c =:p.InventoryReserve__r.Sequence__c and PackList__c = :PLid limit 1]; ShortageQty = requiredQty - PIList.AvailableQty__c; } } }
Please take a look at above code, How do I display the ShortageQty in users locale.
This can be done if we have ShortageQty on the sObject itself. But I want to check if I want to create some Visualforce pages where we want to display some values which are not stored physically and they also not a formula field then how do we leverage the user's locale settings for those columns.
Thanks
Hi wesnolte ,
I have tried using your example from dynamic custom labels - part 2 for following but I am getting an error
<apex:column headerValue="Test">
<apex:outputText value="{0, Number, Integer}">
<apex:param value="500.00"/>
</apex:outputText>
</apex:column>
Error :
global class cProductInventorys{
global String Line {get; set;}
global OpportunityLineItem ShortageQty {get; set;}
global List<ProductInventory__c> PIList{get; set;}
cProductInventorys(ProductInventory__c p, Double requiredQty){
ShortageQty = new OpportunityLineItem();
Id PLid = ApexPages.currentPage().getParameters().get('id');
Line = String.valueOf(p.InventoryReserve__r.Sequence__c);
PIList=[select id,name, InventoryReserve__c, InventoryReserve__r.Sequence__c,WareHouse__c, AvailableQty__c
where InventoryReserve__r.Sequence__c =:p.InventoryReserve__r.Sequence__cand PackList__c = :PLid limit 1];
ShortageQty.Quantity = requiredQty - PIList.AvailableQty__c;
}
}
Any where on your vf page you had this:
<apex:outputText value="{someVar.ShortageQty}"/>
Change to :
<apex:outputField value="{someVar.ShortageQty.Quantity}"/>
Hey
To get your param to work the value needs to be dynamically population ie. it must call a method or public property. For you case however I'm going to say go with TechNrd's solution, it's by far the cleanest way to achieve the desired result.
Cheers,
Wes
Thanks TehNrd,
I am trying to create a inventory inquiry page for opportunity. With this approach I can still see another issue, If the user does not have Create Permission on Opportunity then
ShortageQty = new OpportunityLineItem();
will not work.
I have created another sObject and will have full permission for all profiles on this object and I am using this object to hold ShortageQty .