You need to sign in to do that
Don't have an account?

Rerender visualforce when an item from a picklist is selected
I need to rerender visualforce when a user selects an item from a picklist. I only want to show the records related to the item chosen.
<apex:page standardController="Repository__c" extensions="PrinterDetails" >
<apex:form >
<apex:pageBlock id="thePageBlock" >
<apex:actionRegion >
<apex:pageBlockSection title="Printer Information" columns="1">
<apex:inputField value="{!Repository__c.name"/>
<apex:pageBlockSectionItem>
<apex:outputLabel value="Address Name"/>
<apex:outputPanel>
<apex:inputField value="{!Repository__c.Address_Name__c}">
<apex:actionSupport event="onchange" rerender="thePageBlock" status="status"/>
</apex:inputField>
<apex:actionStatus startText="applying value..." id="status"/>
</apex:outputPanel>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:actionRegion>
<apex:pageblockTable value="{!PrinterDetails}" var="printers" id="table">
<apex:column value="{!printers.name}" headerValue="Serial Number"/>
<apex:column value="{!printers.Address_Name__c}" headerValue="Address Name"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Alex,
Maybe I'm missing something but you want to filter the printer list based on the Address_Name input, right? Then we need a method that takes the input and requeries the Repository, something like: select name, Address_Name__c from Repository__c WHERE Address_Name__c = :foobar. Then call this method with the action parameter of the apex:actionSupport tag. This would be similar to Chamil's calcPricing method in his example except that you need the method to update your printer list values.
You page may, in fact, be refreshing. All rerender will do for you is refresh a section of the existing page. If the data hasn't changed (and I don't see that it does here) then you get the same result.
Of course, I could be wrong. :)
All Answers
This is my Apex class:
public class PrinterDetails {
public PrinterDetails(ApexPages.StandardController controller) {
}
public Repository__c [] getPrinterDetails() {
Repository__c [] printerList;
printerList = [select Repository__c.name, Repository__c.Address_Name__c
from Repository__c];
return printerList;
}
}
Hi Alex,
I have a example for actionsupport with selectlist and get selected value.
Here You can get the selected value by using "discountScheduleID ". By using discountScheduleID variable u can query values.
Try this example and apply to your one.
I hope this will helpful for you
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
Chamil's Blog
Thank you Chamil.
I was trying to apply your example to my case, but I'm not sure how to do it. Can you explain to me what is involved in your code?
I would like to have a Picklist and/or textboxes so users can search for an entry. The outcome should be the objects related to the search. If a user searches for an Address Name, then all the printers that belong to that Address should only show on the screen, and not a full list of printers, which is what I have right now, because the page is not rerendering.
Also, I would like to have a "Search" button that users click to confirm their search.
Can you provide more details or examples?
Thanks.
Alex,
Maybe I'm missing something but you want to filter the printer list based on the Address_Name input, right? Then we need a method that takes the input and requeries the Repository, something like: select name, Address_Name__c from Repository__c WHERE Address_Name__c = :foobar. Then call this method with the action parameter of the apex:actionSupport tag. This would be similar to Chamil's calcPricing method in his example except that you need the method to update your printer list values.
You page may, in fact, be refreshing. All rerender will do for you is refresh a section of the existing page. If the data hasn't changed (and I don't see that it does here) then you get the same result.
Of course, I could be wrong. :)
You are correct, that's exactly what I would like to do. Let me give it a shot and I will let you know if it works. This has been very helpful.
Thanks.
<apex:page name="Queue Criteria" tabStyle="Contact" id="Page" title="Criteria" standardController="Queue_Criteria__c" extensions="QueueCriteriaStdController">
<apex:form id="Form" title="Criteria">
<apex:sectionHeader title="Queue Criteria" subtitle="New Queue Criteria" id="PSHeader"/>
<apex:pageBlock title="Queue Criteria Edit" id="PBlock" tabStyle="Contact" mode="edit">
<apex:pageMessages >
</apex:pageMessages>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}" />
<apex:commandButton value="Save & New" />
<apex:commandButton value="Cancel" action="{!cancel}" />
</apex:pageBlockButtons>
<apex:pageBlockSection title="Information" columns="2" id="PBSection" collapsible="false">
<apex:inputField value="{!Queue_Criteria__c.Name__c}" required="true"/>
<apex:inputField value="{!Queue_Criteria__c.Contact_Name__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection columns="1" collapsible="false" >
<apex:selectList > value="{!Queue_Criteria__c.Operator__c}" required="true" >
<apex:actionSupport event="onmouseover" reRender="UBV2"/>
</apex:selectList>
<apex:inputField value="{!Queue_Criteria__c.Bounded_Value__c}"/>
<apex:inputField value="{!Queue_Criteria__c.UnBounded_Value1__c}" styleClass="hidden"/>
</apex:pageBlockSection>
<apex:outputPanel id="UBV2" >
<apex:pageBlockSection id="pbs" rendered="{!IF((Queue_Criteria__c.Operator__c=='Between'),true,false)}" >
<apex:inputField value="{!Queue_Criteria__c.UnBounded_Value2__c}" />
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
<script>
function callUBV()
{
var Opr=document.getElementById('Page:Form:PBlock:j_id32:j_id33').value;
}
</script>
</apex:page>
Thankyou, But how to compare with the list items to perform some functions...
I mean For very option to compare HOW TO TAKE THEM IN VARIABLE ?
Please share your ideas...!