function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
knicholsknichols 

price list not displaying unless I use two forms

I have a form that displays two price lists but unless I use two forms (like below), they won't show up.

<apex:page standardController="OpportunityLineItem" extensions="addQuoteLineItem">
<apex:form id="mainForm">
<apex:outputPanel id="quoteInfo">
<apex:pageBlock title="Quote Line">
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!save}" value="Save"/>
<apex:commandButton action="{!saveAndNew}" value="Save & New"/>
</apex:pageBlockButtons>
<apex:messages />
<apex:pageBlockSection id="priceData" columns="4">
<apex:pageBlockSectionItem >
<apex:outputText value="Price: "/><apex:inputField id="unitPriceField" value="{!OpportunityLineItem.UnitPrice}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputText value="Quantity: "/><apex:inputField value="{!OpportunityLineItem.Quantity}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
<apex:form >
<apex:selectList value="{!viewProductField}" id="productFields" size="1">
<apex:selectOptions value="{!products}"/>
<apex:actionSupport event="onchange" action="{!refreshPricing}" reRender="priceList,priceListCanada"/>
</apex:selectList>

<apex:outputPanel id="priceList">
<apex:pageBlock title="Pricing" rendered="{!usRendered}">
<apex:pageBlockTable value="{!pricingResult}" var="p">
<apex:column >
<apex:facet name="header">
<apex:outputText value="FOB"/>
</apex:facet>
<apex:outputText value="{!p.FOB__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:outputPanel>
<apex:outputPanel id="priceListCanada">
<apex:pageBlock title="Canadian Pricing" rendered="{!canadaRendered}">
<apex:pageBlockTable value="{!pricingCanadaResult}" var="p">
<apex:column >
<apex:facet name="header">
<apex:outputText value="FOB"/>
</apex:facet>
<apex:outputText value="{!p.FOB__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:page>

 If I use this, it doesn't work.  What's the deal?  We'd like to have the select list at the top of the page but it appears we can't.  Notice I changed where the select list is and removed one form.

 

<apex:page standardController="OpportunityLineItem" extensions="addQuoteLineItem">
<apex:form id="mainForm">
<apex:selectList value="{!viewProductField}" id="productFields" size="1">
<apex:selectOptions value="{!products}"/>
<apex:actionSupport event="onchange" action="{!refreshPricing}" reRender="priceList,priceListCanada"/>
</apex:selectList>
<apex:outputPanel id="quoteInfo">
<apex:pageBlock title="Quote Line">
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!save}" value="Save"/>
<apex:commandButton action="{!saveAndNew}" value="Save & New"/>
</apex:pageBlockButtons>
<apex:messages />
<apex:pageBlockSection id="priceData" columns="4">
<apex:pageBlockSectionItem >
<apex:outputText value="Price: "/><apex:inputField id="unitPriceField" value="{!OpportunityLineItem.UnitPrice}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputText value="Quantity: "/><apex:inputField value="{!OpportunityLineItem.Quantity}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:outputPanel>
<apex:outputPanel id="priceList">
<apex:pageBlock title="Pricing" rendered="{!usRendered}">
<apex:pageBlockTable value="{!pricingResult}" var="p">
<apex:column >
<apex:facet name="header">
<apex:outputText value="FOB"/>
</apex:facet>
<apex:outputText value="{!p.FOB__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:outputPanel>
<apex:outputPanel id="priceListCanada">
<apex:pageBlock title="Canadian Pricing" rendered="{!canadaRendered}">
<apex:pageBlockTable value="{!pricingCanadaResult}" var="p">
<apex:column >
<apex:facet name="header">
<apex:outputText value="FOB"/>
</apex:facet>
<apex:outputText value="{!p.FOB__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:page>

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
jwetzlerjwetzler

I'm not sure why it doesn't work... not much detail to go on.  Generally what happens is there's some sort of validation that's failing because of the form submit that happens form the actionSupport.  Use actionRegion to control the parts of your form that get submitted.  Should be doable using only one form and one or more actionRegion (for starters you'll want an actionRegion around your selectList only I would guess).

 

If you put a apex: pageMessages component on your page you should see any validation errors.

All Answers

jwetzlerjwetzler

I'm not sure why it doesn't work... not much detail to go on.  Generally what happens is there's some sort of validation that's failing because of the form submit that happens form the actionSupport.  Use actionRegion to control the parts of your form that get submitted.  Should be doable using only one form and one or more actionRegion (for starters you'll want an actionRegion around your selectList only I would guess).

 

If you put a apex: pageMessages component on your page you should see any validation errors.

This was selected as the best answer
knicholsknichols
Jill surrounding my list in an actionRegion worked(with only one form).  I never would have thought to do that, thanks!